Hello,
This example code was taken from stackoverflow.
data have; input MERCH_NO V01 M02 V08 M08 AMOUNT PLAN $; calc = input(vvaluex(plan),best12.) * amount; put calc=; datalines; 123456 2 2 1 1 100.00 V01 456789 4 4 4 4 250.00 M08 ;;;; run;
Can vvaluex be regarded as kind of macro variable resolution? In this example, value of V01 is 2.
I replicated the outout with this code.
%let V01 = 2;
%let M08 = 4;
data test;
set have;
calc= input(symget(plan),best.)*amount;
run;
@SAS_inquisitive wrote:
Can vvaluex be regarded as kind of macro variable resolution? In this example, value of V01 is 2.
No. VVALUEX returns the value of a variable. It can have nothing to do with macro variables.
You create macro variables but don't use them so your example doesn't quite make sense.
@Reeza wrote "You create macro variables but don't use them so your example doesn't quite make sense".
I am creating those macro variables and using symget function to get values. Basically, I was trying to do same thing as vvaluex function does using symget in this example.
If you know your macro variable(s) contain numeric strings (all macro variables are character strings) you can use the SYMGETN() function to read it directly into a numeric variable and skip the INPUT() function call.
%let V01 = 2;
%let M08 = 4;
data want;
input plan $ amount ;
calc= symgetn(plan)*amount;
cards;
V01 3.4
M08 4.5
;
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.