楼主: oxygenmz
2066 6

[原创博文] 请教一个Macro 题。。。 [推广有奖]

  • 0关注
  • 0粉丝

本科生

10%

还不是VIP/贵宾

-

威望
0
论坛币
3 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
832 点
帖子
62
精华
0
在线时间
71 小时
注册时间
2009-4-30
最后登录
2016-6-3

楼主
oxygenmz 发表于 2010-1-22 14:43:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
sashelp.prdsale totalobs 明明大于10, 为什么RC最后的结果是 LOW...?  谢谢了~

options symbolgen;
%let rc=Begin;
%macro test;
data out;
set sashelp.prdsale nobs=totalobs;
if totalobs > 10 then do;
%let rc=high;
end;
else do;
%let rc=low;
end;
run;
%mend;
%let rc= Before Execution;
%test
%put answer: &rc;




二维码

扫码加我 拉你入群

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

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

关键词:Macro acr CRO Mac EXECUTION

回帖推荐

funnyxuke 发表于5楼  查看完整内容

%let rc=Begin; %macro test; data out; set sashelp.prdsale nobs=totalobs; new=totalobs; %if totalobs >10 %then %do; %let rc=high; %end; %else %do; %let rc=low; %end; run; %mend; %let rc= Before Execution; %test %put answer: &rc; 这样就变high了 1# oxygenmz

本帖被以下文库推荐

沙发
soporaeternus2 发表于 2010-1-22 19:54:26
SAS仅依次解析了
  1. %let rc=high
复制代码
  1. %let rc=low
复制代码
各一遍
故&rc 值是low

这里可能使用call symput会好些

%语句 仅仅是文本替换而已

藤椅
oxygenmz 发表于 2010-1-23 00:27:21
哦~谢谢~ 我苦思冥想了很久:S

板凳
henryx 发表于 2010-1-23 03:13:00
3# oxygenmz

编译次序造成的;

报纸
funnyxuke 发表于 2010-1-23 08:00:41
%let rc=Begin;
%macro test;
data out;
set sashelp.prdsale nobs=totalobs;
new=totalobs;
%if totalobs >10 %then %do;
%let rc=high;
%end;
%else %do;
%let rc=low;
%end;
run;
%mend;
%let rc= Before Execution;
%test
%put answer: &rc;


这样就变high了













1# oxygenmz
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

地板
bobguy 发表于 2010-1-23 10:32:32
oxygenmz 发表于 2010-1-22 14:43
sashelp.prdsale totalobs 明明大于10, 为什么RC最后的结果是 LOW...?  谢谢了~

options symbolgen;
%let rc=Begin;
%macro test;
data out;
set sashelp.prdsale nobs=totalobs;
if totalobs > 10 then do;
%let rc=high;
end;
else do;
%let rc=low;
end;
run;
%mend;
%let rc= Before Execution;
%test
%put answer: &rc;




Others already pointed out where the problem is.

Here is a simpler version of you codes.

%macro nobs(dsn=);
    data _null_;
      if 0 then set &dsn nobs=nobs;   ***note nobs is available at compiling time. Not needed to open it and read it;
      if nobs >10 then call symputx('rc','High');
      else  call symputx('rc','Low');
    run;
    %put rc=&rc;
%mend;

%nobs(dsn=sashelp.class)
data t1;
x=1;
run;
%nobs(dsn=t1)

7
oxygenmz 发表于 2010-1-23 12:04:26
  谢谢热情回复~

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 01:56