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

Hi All,

 

I am trying to import an Excel file (.xlsx), which currently sits on the server.

The query i have been trying to run is as below:

 

Proc import datafile=New_File_&Pdate..xlsx (&Pdate:is a macro assigned for previous day)

out=Prev_File

dbms=XLSX;

Getnames=Yes;

run;

 

However, i have been getting this error:

 

16 Proc import datafile=New_File_&Pdate..xlsx

NOTE: Line generated by the macro variable "PDATE".

16 New_File_18JUL2016

_________________

22

201

NOTE: PROCEDURE IMPORT used (Total process time):

real time 0.00 seconds

cpu time 0.00 seconds

 

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

ERROR 201-322: The option is not recognized and will be ignored.

 

 

Can you please help me understand, what the error is.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
DJongman
Obsidian | Level 7

I can't explain exactly your error, but tested the next code below and that is working:

 

%let pdate =  %sysfunc(putn(%eval(%sysfunc(today())-1),date9.));

Proc import out = work.xlsdat
	datafile = "c:\New_File_&pdate.xlsx"
	dbms = xlsx replace;
	getnames = yes;
run;

Maybe you can use this for you own macro.

 

 

View solution in original post

4 REPLIES 4
Ksharp
Super User

You need put double QUOTE around it .

 

 

Proc import datafile="c:\temp\New_File_&Pdate..xlsx" replace

out=Prev_File

dbms=XLSX;

Getnames=Yes;

run;

Yvegunta
Obsidian | Level 7

Thank you KSharp.

 

DJongman
Obsidian | Level 7

I can't explain exactly your error, but tested the next code below and that is working:

 

%let pdate =  %sysfunc(putn(%eval(%sysfunc(today())-1),date9.));

Proc import out = work.xlsdat
	datafile = "c:\New_File_&pdate.xlsx"
	dbms = xlsx replace;
	getnames = yes;
run;

Maybe you can use this for you own macro.

 

 

Yvegunta
Obsidian | Level 7

Thanks DJongman.

I used your method and tweaked it a bit and it was the exact output i wanted.

 

Thanks again.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 4 replies
  • 2120 views
  • 4 likes
  • 3 in conversation