DATA Step, Macro, Functions and more

SAS import query

Reply
Contributor scb
Contributor
Posts: 69

SAS import query

 

I can't import the below excel file.  Please advise.  Thanks.


%let yyyymm=201604;

PROC IMPORT OUT=car_&YYYYMM
DATAFILE="c:\car_&yyyymm.xlsx"
DBMS=EXCEL REPLACE;
getnames=YES;
RUN;

PROC Star
Posts: 7,490

Re: SAS import query

You said you can't import the file. A couple of questions:

 

Does your site license SAS/Access for PC File Formats? 

What kind of error message are you getting?

Have you tried DBMS=XLSX

Is your workbook actually located in the root of the c: drive?

 

Art, CEO, AnalystFinder.com

 

 

Super User
Super User
Posts: 7,988

Re: SAS import query

[ Edited ]

I would advise to post relevant information.  What does the log say for instance?  Do you have access to that file (i.e. SAS UE runs on its on virtual image so no CSmiley Happy.  From what you have posted its versy hard to even tell what you are trying.  Check this line in the log:

DATAFILE="c:\car_&yyyymm.xlsx"

 

Is there a space between the macro and the .xlsx for instance, if so then:

DATAFILE="c:\car_%trim(&yyyymm.).xlsx

 

Oh, and typing that I have just seen what the problem is.  A macro variable needs a dot after it, so this resolves to:

c:\car_201604xlsx"

 

Which is wrong.  You need a dot to end the macro variable and a dot before the extension like:

DATAFILE="c:\car_&yyyymm..xlsx"

Ask a Question
Discussion stats
  • 2 replies
  • 122 views
  • 0 likes
  • 3 in conversation