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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.