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 2025: Call for Content

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!

Submit your idea!

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
  • 729 views
  • 0 likes
  • 3 in conversation