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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.