BookmarkSubscribeRSS Feed
SAS_inquisitive
Lapis Lazuli | Level 10

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;

3 REPLIES 3
Reeza
Super User

@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.

SAS_inquisitive
Lapis Lazuli | Level 10

@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.

Tom
Super User Tom
Super User

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
;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1091 views
  • 2 likes
  • 3 in conversation