I have a macro in which there are keyword parameters like this. colvars=C1 C3 C6 , collabl1=SCLC|(N=&m_C1)|n(%), collabl2=NSCLC|Non-Squamous|(N=&m_C3)|n(%), collabl3=GEJ|(N=&m_C6)|n(%), This will assign my title column lables in my output report. I want to automate this by getting the number of variables in the data. If there are 4 vars in the data it should automate by knowing there are 4 variables in the dataset and get that information into the macro. colvars=C1 C2 C3 C5 , collabl1=SCLC|(N=&m_C1)|n(%), collabl2=NSCLC|Squamous|(N=&m_C2)|n(%), collabl3=ESCC|(N=&m_C3)|n(%), collabl4=GEJ|(N=&m_C6)|n(%), I want to automate this and get these steps into the macro call, based on the number of variables in the dataset. %rtf(inds=final, rowheadvars=rowhead1 rowhead2, rowheadlabel=, colvars=C1 C3 C6 Czz, collabl1=SCLC|(N=&m_C1)|n(%), collabl2=NSCLC|Non-Squamous|(N=&m_C3)|n(%), collabl3=GEJ|(N=&m_C6)|n(%), collabl4=Total|(N=&m_Czz)|n(%), colwidths=39 15 15 15 15, lindent=700, sortordvars=varord ordvar1, linespp=18, orientation=landscape ); I have created the list of vars and the count of vars but couldnt able to figure out how to iterate them into the macro. final is the dataset from which i am taking the nonmissing vars. proc sql noprint; select distinct name into :vars separated by ' ' from dictionary.columns where memname = 'FINAL' and prxmatch("m/C1|C2|C3|C4|C5|C6|CZZ/oi",strip(name))> 0 order by varnum; quit; %let cntlist = &sqlobs; %put &vars. ; %put &cntlist. ; options mlogic mprint symbolgen; %macro wordcount(list); %local count; %let count=0; %do %while(%qscan(&list,&count+1,%str( )) ne %str()); %let count = %eval(&count+1); %end; %mend wordcount; proc format ; value $chrt "C1" = "SCLC" "C2" = "NSCLC|Squamous" "C3" = "NSCLC|Non-Squamous" "C4" = "HNSCC" "C5" = "ESCC" "C6" = "GEJ"; "CZZ" = "Total"; ; quit; run;
... View more