Hi, When I try these 2 programs, it works perfect. Except that, I am not able to use '&first'. My Problem is: All the dataset has different first variable names. It might be either one word or two words. How can I solve that. Thanks for all your help. Program 1. ---------------------------------------------------------------------------------------- data have ; set in_nyma_protocol; array _x _numeric_; run; proc sql noprint; select catx('=',name,'VAR'||put(varnum,z3.)) into :rename separated by ' ' from dictionary.columns where libname='WORK' and memname='HAVE' and varnum ne 1; ; quit; data want ; set have (rename=(&rename)); run; ------------------------------------------------------------------------------------- Program 2 --------------------------------------------------------------------------------- %let dsn=want; %let ndays=8; proc sql noprint; select min(name), max(name),max(varnum)-1,(max(varnum)-1)/&ndays. into :first, :max,:maxvar,:days from dictionary.columns where libname="WORK" and memname=upcase("&dsn.") ; select name into :min from dictionary.columns where libname="WORK" and memname=upcase("&dsn.") and varnum=2 ; quit; data daily_tot_&dsn(keep= total day:); set &dsn.; /* length category $25; category=&first.; */ format total 20.; array _data(*) &min.--&max.; array day(&days.); array _days(&ndays.); total=sum(of _data(*)); do i=1 to &days.; do j=1 to &ndays.; _days(j)=_data((i-1)*&ndays.+j); end; day(i)=sum(of _days(*)); end; run; __________________________________________________
... View more