BookmarkSubscribeRSS Feed
weizhongma
Calcite | Level 5

Hi There,

 

I ecountered this issue when I tried to use X command to open a file and file name has a macro variable: &basedt2.

 

X '"C:\Ma Project\01 Angeliebe daily tracking\raw data\ReportCustomerCsv-&basedt2..csv"';

 

It can not be executed.

 

Does anyone have a solution?

 

Thanks!

 

 

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Two things, first you need to put

options mlogic symbolgen mprint;

 

Before that call and see what the macro variable relates to.  Then check that file exists - simple way of checking is to open a cmd window, then copy an dpaste the full text (not the macro variable) into the cmd window and see what it says.  Likely the path is wrong, or you have spaces.  Also note where you are running it.  It will have to be on a windows machine and have Excel installed and associated with .csv, otherwise the OS does not know what software to open it with.

 

And a final question, why?  It seems totally pointless to open file on the OS.

Reeza
Super User

Why do you have single and double quotes? 

Use only the double quotes. 

Astounding
PROC Star

Where is the command?  You have a path to a file, but X requires a system-based command that it will execute.  

 

Are you saying this command sometimes does what you want if you don't refer to a macro variable within?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, not quite @Astounding.  If the file type is known by the system, in this case CSV is associated with Excel, then it actually opens Excel and then file.  Thats why I was questioning the reason behind it, opening the file, as SAS already has the options results which will open output files when created.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 2207 views
  • 0 likes
  • 5 in conversation