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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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