Hi,
I would like to know how to automatically determine the number of items in & type(=26) instead of declaring 26 in the below script....
Just a very simple example:
%let type= A B C D E F G H I J K L M N O P R S T U V W X Y Z ;
data _NULL_;
do i = 1 to 26; <---- this value of 25 is what I would like to automate when I change &type.
put Number=i ;
end;
run;
Assuming they're always space separated then the countw function should do the trick like so
%let type= A B C D E F G H I J K L M N O P R S T U V W X Y Z;
data _NULL_;
do i = 1 to countw("&type");
put Number=i ;
end;
run;
Assuming they're always space separated then the countw function should do the trick like so
%let type= A B C D E F G H I J K L M N O P R S T U V W X Y Z;
data _NULL_;
do i = 1 to countw("&type");
put Number=i ;
end;
run;
This may be a useful example for you:
and some more are here:
Your links are super helpful. Thanks so much!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.