BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Juanjuan
Fluorite | Level 6

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="&paramcd." 
    ;
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;
1 ACCEPTED SOLUTION

Accepted Solutions
Juanjuan
Fluorite | Level 6

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;

 

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Juanjuan
Fluorite | Level 6

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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 806 views
  • 0 likes
  • 2 in conversation