06-18-2012 02:14 PM
I have used the following macro to count the number of rows and use it in my dde:
if 0 then set TEST nobs=nr;
CALL SYMPUT('row2', PUT(index, 5.));
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.
06-18-2012 03:18 PM
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
set sashelp.class nobs=obs;
call symputx('vars',countc(catx('09'x,of _all_),'09'x)+1);
or dictionary tables (separated by removes leading spaces in macro vars)...
proc sql noprint;
select nobs+1, nvar into bs separated by ' ', :vars separated by ' '
where libname eq 'SASHELP' and memname eq 'CLASS';
06-18-2012 10:54 PM
Or compressing code.
%put &nvar ;