I try to use a macro variable "num" like this,
proc sql;
select max(num) into :num
from dsn2;
quit;
data asd2;
set asd;
array a _COL3-_COL#
arrat b COL3-COL#
do i= 1 to dim(&num);
b(i)=input(a(i),best12.);
run;
well, it doesn't work, but if I do this, It seems works
proc sql;
select max(num) into :num
from dsn2;
quit;
*******;
%let numb=#
data asd2;
set asd;
array a _COL3-_COL&numb;
arrat b COL3-COL&numb;
do i= 1 to dim(&numb);
b(i)=input(a(i),best12.);
run;
I don't why.
Anyone can pls tell me? THX!
%LET eliminates any leading and trailing blanks.
%LET eliminates any leading and trailing blanks.
so you mean when using
proc sql;
select max(num) into :num
from dsn2;
quit;
"num" actually contains blanks?
Try this and you will see:
%put col#
%let num=#
%put col#
You are right!!
THX!!!
You also have a syntax error in your interative DO statement. Either pass the name of the array to the DIM() function or just use the macro variable as the upper bound on the array.
do i= 1 to dim(A);
do i= 1 to #
There were a couple of other errors in the original post (DO without END and ARRAY misspelled "arrat"). I suspect that rpg163 might have the same problem that I do with these forums - not being able to paste code into the editor.
You can use Ctrl + c and Ctrl + v to bring your code into the forum.
Another workaround is using macro function to trim these blanks.
%let num=%trim(%left(&num));
Ksharp
THX! I will try this.
You are right.
I missed sth. here.
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.