楼主: zw612003
1490 4

含有H&M的宏变量在""中M如何不被解析[已解决] [推广有奖]

  • 1关注
  • 1粉丝

本科生

27%

还不是VIP/贵宾

-

威望
0
论坛币
835 个
通用积分
1.0035
学术水平
2 点
热心指数
5 点
信用等级
1 点
经验
1294 点
帖子
102
精华
0
在线时间
66 小时
注册时间
2011-11-5
最后登录
2015-3-7

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
代码如下:
  1. data code;
  2. input code $3. prod_des $20.;
  3. cards;
  4. M22 H&M (Shop)
  5. ;
  6. run;
  7. data _null_;
  8. set code;
  9. call symput (cat('code',_n_),strip(code));
  10. call symput (cat('gdesc',_n_),strip(prod_des));
  11. call symput ('numgenp', strip(put(_n_,12.))); /* by Jovi, NOTE: Numeric values have been converted to character values*/
  12. run;
  13. %macro macro_format;
  14. proc format;
  15. value  $gencode
  16.     %do i=1 %to &numgenp.;
  17.     "&&code&i" = "&&gdesc&i"
  18.    %end;
  19.    other   = "Unknown"
  20.    ;
  21. %mend macro_format;
  22. %macro_format;
复制代码
Log:
MPRINT(MACRO_FORMAT):   proc format;
WARNING: Apparent symbolic reference M not resolved.
MPRINT(MACRO_FORMAT):   value $gencode "M22" = "H&M (Shop)" other = "Unknown" ;
NOTE: Format $GENCODE is already on the library.
NOTE: Format $GENCODE has been output.

怎么样才可以不出桔黄色的Warning?试了各种%str,%nrstr,%nrbquote,不知道怎么正确使用才能不出warning。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:已解决 converted Reference Character Symbolic character records values null

沙发
juliewong 在职认证  发表于 2013-12-8 20:29:53 |只看作者 |坛友微信交流群
好高深

使用道具

藤椅
A072560 发表于 2013-12-8 20:46:24 |只看作者 |坛友微信交流群
这个不就是做FORMAT吗?你直接用DATA 步做也是一样的,
data code;
input LABEL $3. START $20.;
FMTNAME="$SEARCH";
cards;
M22 H&M (Shop)
;
run;

PROC FORMAT CNTLIN=CODE;
RUN;

使用道具

板凳
bobguy 发表于 2013-12-9 03:23:59 |只看作者 |坛友微信交流群
The macro quoting part is the most difficult in learning SAS macros. In this case you need a %superq quoting function as below.

The %superq quoting function masks all special characters and mnemonic operators at macro execution but prevents further resolution of the value.

Please note the argument form is slightly different (&&gdesc&i --> gdesc&i).

507
508      %macro macro_format;
509      proc format;
510      value  $gencode
511          %do i=1 %to &numgenp.;
512          "&&code&i" = "%superq(gdesc&i)"
513         %end;
514         other   = "Unknown"
515         ;
516         run;
517      %mend macro_format;
518
519      
520      %macro_format;
MPRINT(MACRO_FORMAT):   proc format;
MPRINT(MACRO_FORMAT):   value $gencode "M22" = "H&M (Shop)" other = "Unknown" ;
NOTE: Format $GENCODE is already on the library.
NOTE: Format $GENCODE has been output.
MPRINT(MACRO_FORMAT):   run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

使用道具

报纸
zw612003 发表于 2013-12-9 09:32:04 |只看作者 |坛友微信交流群
bobguy 发表于 2013-12-9 03:23
The macro quoting part is the most difficult in learning SAS macros. In this case you need a %superq ...
Thank you so much. I spent almost 10 hours to fix this. Thank you so so much!! This forum is amazing~~

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-2 01:22