BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
%let path=C:\inputfile;
%macro import_xls(dat);
PROC IMPORT OUT= &dat
DATAFILE= "&path.\may data.xls"
DBMS=EXCEL REPLACE;
SHEET="&dat";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;

RUN;
%mend;
%import_xls(ABC_2009_05);
%import_xls(pqr_2009_05);

I will have data from 16 vendors saved in 16 tabs under may data.xls. I will be creating sas datasets.
for each dataset I will have to create two extra fields provider and filedate.
for example:
data ABC_2009_05;
set ABC_2009_05;
provider='ABC';
filedate='2009-05';
run;

I tried this piece of code:
data &dat;
set &dat;
provider=scan(&dat,1,'_');
filedate=scan(&dat,2,'_')||'-'||scan(&dat,3,'_');
run;

But &dat is not getting resolved!
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12
The data step has to be inside the import_xls macro to "see" the value.
deleted_user
Not applicable
Declare
%let dat = ;

before calling the macro.
i.e. before:
%import_xls(ABC_2009_05);

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 985 views
  • 0 likes
  • 3 in conversation