Scan function causes problems in proc import

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 94
Accepted Solution

Scan function causes problems in proc import

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!


Accepted Solutions
Solution
‎02-22-2018 11:06 AM
Super User
Posts: 6,781

Re: Scan function causes problems in proc import

Posted in reply to Uknown_user

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


All Replies
SAS Employee
Posts: 30

Re: Scan function causes problems in proc import

Posted in reply to Uknown_user
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.
Frequent Contributor
Posts: 94

Re: Scan function causes problems in proc import

Posted in reply to GinaRepole

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

 

picture.png

Frequent Contributor
Posts: 94

Re: Scan function causes problems in proc import

[ Edited ]
Posted in reply to Uknown_user

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...?

Frequent Contributor
Posts: 94

Re: Scan function causes problems in proc import

Posted in reply to Uknown_user

This also did not work:

 

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

Solution
‎02-22-2018 11:06 AM
Super User
Posts: 6,781

Re: Scan function causes problems in proc import

Posted in reply to Uknown_user

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

 

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

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 124 views
  • 0 likes
  • 3 in conversation