Hi,
Your requirements are confusing. You should not need to remove quotes on the %PUT statement.
The main problem here is that the quote marks are not part of the macro language, and you have an extra set of parentheses. If you want to store the code to generate a random number in a macro variable, the easiest way would be to change the value of the macro variable so that the code can be executed by %sysfunc:
1 %let gen=rand(uniform) ; *This stores code in a macro variable ;
2 %put &=gen ;
GEN=rand(uniform)
3 %put %sysfunc(&gen) ; *This uses sysfunc to execute the stored code ;
0.53809128166176
4 %put %sysfunc(&gen) ;
0.37165963975712
If you cannot change the value of gen for some reason, then as others have pointed out, you can create a new macro var with the correct code:
1 %let gen=(rand('uniform')); *This value has unwanted quotes and extra set of parentheses ;
2 %put &=gen ;
GEN=(rand('uniform'))
3
4 *remove the parentheses ;
5 %let gen2=%sysfunc(substr(&gen,2,%sysfunc(length(&gen))-2)) ;
6 %put &=gen2 ;
GEN2=rand('uniform')
7
8 *remove the quotes ;
9 %let gen3=%sysfunc(compress(&gen2,%str(%')));
10 %put &=gen3 ;
GEN3=rand(uniform)
11
12 %put %sysfunc(&gen3);
0.639510035282
13 %put %sysfunc(&gen3);
0.41172609385102
... View more