Hi guys,
I have used the following macro to count the number of rows and use it in my dde:
data _NULL_;
if 0 then set TEST nobs=nr;
index=nr+1;
CALL SYMPUT('row2', PUT(index, 5.));
stop;
run;
usage in DDE: FILENAME dataZ13 DDE "excel|[&template.]§ion2.!r2c30:r&row2.c36" notab;
I am wondering how I can do the same for the number of columns? I have a dataset where we add a new variable (column) every month. I was wondering if there was some similar macro that can count the number of columns so I do not have to keep changing the column limits in DDE.
Thanks.
hi ... one idea (use a separator that's not a character in your data ... I used a TAB) ...
question ... what's that +1 for (index=nr+1) ... it's added in both examples below
data _null_;
set sashelp.class nobs=obs;
call symputx('obs',obs+1);
call symputx('vars',countc(catx('09'x,of _all_),'09'x)+1);
stop;
run;
or dictionary tables (separated by removes leading spaces in macro vars)...
proc sql noprint;
select nobs+1, nvar into :obs separated by ' ', :vars separated by ' '
from dictionary.tables
where libname eq 'SASHELP' and memname eq 'CLASS';
quit;
Or compressing code.
%let dsid=%sysfunc(open(sashelp.class));
%let nvar=%sysfunc(attrn(&dsid,nvar));
%let dsid=%sysfunc(close(&dsid));
%put &nvar ;
Ksharp
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!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: