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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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.

Singham20
Obsidian | Level 7

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

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
  • 2 replies
  • 2330 views
  • 0 likes
  • 2 in conversation