BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GeraldKoye
Fluorite | Level 6

Is it possible to use an excel file of parameters (allowance tax, expense fee ...) that sas can read and interpret as variables in the project?

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

First, you need to make sure that the names are valid SAS names (contain only letters, digits and underscores - no blanks! - and start with a letter or underscore). Then you use CALL SYMPUT or CALL SYMPUTX in a data step:

data _null_;
set from_excel;
call symputx(name,value,'g');
run;

The 'g' is only there to make sure that the macro variables are put into the global symbol table, if the step is run in a macro.

View solution in original post

6 REPLIES 6
GeraldKoye
Fluorite | Level 6
yes! exactly
Kurt_Bremser
Super User

First, you need to make sure that the names are valid SAS names (contain only letters, digits and underscores - no blanks! - and start with a letter or underscore). Then you use CALL SYMPUT or CALL SYMPUTX in a data step:

data _null_;
set from_excel;
call symputx(name,value,'g');
run;

The 'g' is only there to make sure that the macro variables are put into the global symbol table, if the step is run in a macro.

GeraldKoye
Fluorite | Level 6

Thanks for your answer.

I've tried but. I don't know how to print the variables.

data work.variables;
infile datalines4 dlm='7f'x 
missover dsd ;
input 
nom : $char5. 
valeur : best2. ; 
datalines4; 
taux1 50 
taux2 60 
;;;;  ok

data _null_; 
set variabledata;
call symputx(nom,valeur,'g');
 run;
%put taux1;
%put taux2;
Kurt_Bremser
Super User

To invoke the macro processor to resolve a macro variable, you need to use the macro trigger &:

%put &taux1.;

It is also good practice to terminate a macro variable reference with a dot, to prevent ambiguities if it is used in a word.

GeraldKoye
Fluorite | Level 6

It work! Thanks!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1276 views
  • 3 likes
  • 2 in conversation