i want to run the macro %anova_wocf_mi in several visits. But the program only execute one time (where avisitn=6). Is any issue with my program?
data avisit;
length paramcd chg $8;
mi=1;
paramcd = "NPS0203";
do i =6, 7, 8, 9, 10;
avisitn = i;
chg=compress(catx('','chg',i));
output;
end;
paramcd = "LMS0108";
do i =8, 10;
avisitn = i;
chg=compress(catx('','chg',i));
output;
end;
paramcd = "UPSIT101";
do i =3, 6, 7, 8, 10;
avisitn = i;
chg=compress(catx('','chg',i));
output;
end;
paramcd = "FEV1";
do i = 6, 7, 8, 10;
avisitn = i;
chg=compress(catx('','chg',i));
output;
end;
run;
%let paramcd=NPS0203;
proc sql noprint;
select avisitn into: vis separated by "-"
from avisit
where paramcd="¶mcd."
;
quit;
%put &vis;
%include mac_a(anova_wocf_mi.sas);
%macro loop;
%do i=1 %to %sysfunc(countw(&vis,%str(-)));
%let ppp=%scan(&vis,&i, -);
%put &ppp;
%anova_wocf_mi(paramcd=NPS0203, avisitn=&ppp., censornum=2, popoth=);
%end;
%mend loop;
%loop;
Thanks a lot. this is because before the model, we have to impute the data by MI and WOCF which is different by different visits.
The issue has been fixed now. that's because there is another do loop which use i as index in %anova_wocf_mi macro. if i is replaced by jj, then the do loop will be fine.
%macro loop;
%do jj=1 %to %sysfunc(countw(&vis,%str(-)));
%let visn=%scan(&vis,&jj, -);
%put &visn;
%ancova_wocf_mi(paramcd=NPS0203, avisitn=&visn., censornum=2, popoth=);
%end;
%mend loop;
%loop;
Why do it that way in the first place? SAS i built on the concept of by group processing, which is simpler coding, more robust, and faster.
proc anova data=...; by avisitn; class ...; model Relief = .../...; run;
That code can replace all of what you have from %let onward.
Thanks a lot. this is because before the model, we have to impute the data by MI and WOCF which is different by different visits.
The issue has been fixed now. that's because there is another do loop which use i as index in %anova_wocf_mi macro. if i is replaced by jj, then the do loop will be fine.
%macro loop;
%do jj=1 %to %sysfunc(countw(&vis,%str(-)));
%let visn=%scan(&vis,&jj, -);
%put &visn;
%ancova_wocf_mi(paramcd=NPS0203, avisitn=&visn., censornum=2, popoth=);
%end;
%mend loop;
%loop;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.