Data test;
length var1 $10 var2 $ 20 var3 $25;
run;
Data test;
set test;
var1="";
var2="";
var3="";
%let columnlength=round(ranuni(0)*25,1);
/*25 represent the column length of var3. The question is how to get this value to put it into this function. I would like to do the same for each variable*/
do i=1 to &ColumnLength.;
var3=catt(var3,byte(int(97+26*ranuni(0))));
end;
run;
Use an array in your datastep, then use the vlength function to get the length and the call symputx function to create the macro variable (although why, and why the ranuni is another question).
data test;
set test;
array var{3};
do i=1 to 3;
call symputx(cats('var',put(i,best.)),vlength(var{i}));
end;
run;
Use an array in your datastep, then use the vlength function to get the length and the call symputx function to create the macro variable (although why, and why the ranuni is another question).
data test;
set test;
array var{3};
do i=1 to 3;
call symputx(cats('var',put(i,best.)),vlength(var{i}));
end;
run;
I would guess the OP is attempting to get a random lower case letter if working on an ASCII system.
yes
Very simple!
Thank a lot
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.