Executing a X Command with macro

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Executing a X Command with macro

Hi everyone!

I am trying to copy and rename a bunch of files on my computer and thought X commands is the way to go.  I tried it and it worked perfectly however when I put in a Macro to do this it does not work.  it just saves the first file with the name stated and does not replace the "&name"  with name given.  Here is what I have written so far:

 

%FAST(2017,Carry,05T);

 

%macro FAST(YEAR,SURVEY,MO);

X "copy ""C:\TestSASCode\&YEAR\&SURVEY\&MO\test.DAT"" ""C:\TestSASCode\SAS\&SURVEY_&YEAR_&MO_2017-carrier.DAT"" ";

%mend;

%FAST(2017,Carry,01T);

%FAST(2017,Carry,02T);

%FAST(2017,Carry,03T);

 

I know it looks like I do not need the &Year and &survey because they are the same however I will be doing this for different year and surveys too.  I just wanted the question to be simple.

 

What do you guys think I should do? 

Thank you!


Accepted Solutions
Solution
‎09-11-2017 02:04 PM
Super User
Posts: 23,262

Re: Executing a X Command with macro

[ Edited ]
Posted in reply to Singham20

Add periods after the macro variables. 

If you run the code with the following the log will have more information that helps with debugging.

 

options mprint symbolgen;

&SURVEY._&YEAR._&MO.

View solution in original post


All Replies
Solution
‎09-11-2017 02:04 PM
Super User
Posts: 23,262

Re: Executing a X Command with macro

[ Edited ]
Posted in reply to Singham20

Add periods after the macro variables. 

If you run the code with the following the log will have more information that helps with debugging.

 

options mprint symbolgen;

&SURVEY._&YEAR._&MO.

Occasional Contributor
Posts: 6

Re: Executing a X Command with macro

Thank you so much!  I cannot believe I overlooked that.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 162 views
  • 0 likes
  • 2 in conversation