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);

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 672 views
  • 0 likes
  • 3 in conversation