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

Hi,

 

I am trying to figure out why below mentioned code is not working (problem occurs at out= statement, when I set out=a by hard, it works but creates just one file clearly...):

 

%let list_of_names =  first second third;


%macro _loop();

%do i = 1 %to 4/*%sysfunc(countw(&list_of_names))*/;

proc import datafile = "\\someAddress\%scan(&list_of_names, &i).csv"
     out=%scan(&list_of_names, &i)
     dbms=csv
     replace;
     getnames=yes;
run;

%end;

%mend _loop;
%_loop();

Thanks for your suggestions!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

That's a good line of thought, implementing it would be even simpler than what you tried:

 

out=_%scan(&list_of_names, &I)

View solution in original post

5 REPLIES 5
GinaRepole
SAS Employee
Could you be a little bit more explicit about what your error is? I've run this program modified for a valid path and csv files on my PC and it works perfectly for me.
Uknown_user
Quartz | Level 8

Hi, yes, here I am posting a picture of the error returned:

 

picture.png

Uknown_user
Quartz | Level 8

I assume its problem is a string dsn starting with int..looks like I will have to rename it in some way, otherwise there is some other option...?

Uknown_user
Quartz | Level 8

This also did not work:

 

out='_'||%scan(&list_of_names, &i)

Astounding
PROC Star

That's a good line of thought, implementing it would be even simpler than what you tried:

 

out=_%scan(&list_of_names, &I)

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