BookmarkSubscribeRSS Feed
mlapradd
Calcite | Level 5

I am having a Strange situation which I was hoping someone could explain why it is occurring.  I am trying to use a simple macro variable to count from 1 to 57 in order to import 57 files.

I initially was given files with the name "Simple_toothhistory_1" "Simple.....2" etc.

I used the variable j and had a working macro using "C:\location\Simple_toothhistory_&j..csv"

An issue was found with the files and they were re-converted into csv files with a new name "Prac1_simple_toothhistory" "Prac2_....."

etc. 

I tried to use the macro"C:\location\Prac&j_simple_toothhistory..csv"

but with no luck.  I also tried adding an additional underscore "C:\location\Prac_&j_simple_toothhistory..csv"

But this also did not work. 

I have at this point renamed all 57 files 😞  But I was hoping to understand why it is working at the end but not within the file name!

Thanks!!!

 

1 REPLY 1
Reeza
Super User

Add a period after the &J -> otherwise the compiler doesn't know where your macro variable name ends, so it won't resolve properly. 

 

ie you see:

 

"C:\location\Prac&j_simple_toothhistory..csv"

 

the compiler sees:

 

"C:\location\Prac&j_simple_toothhistory..csv"

 

Note the double period before the CSV name. One of those was for the macro variable to resolve properly but you didn't move it with the macro variable.

 

Correct:

 

"C:\location\Prac&j._simple_toothhistory.csv"

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
  • 1 reply
  • 1413 views
  • 2 likes
  • 2 in conversation