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

After Reading multiple threads i'm able to write below code, but not getting output...

 

Please help !!

 

Code : 

 

libname abc 'C:\Users\Sony\Desktop\datasets';
OPTIONS SYMBOLGEN;

proc sql noprint;
select memname into: names seprated by ''
from Dictionary.tables
where libname="ABC" ;
quit;

data want;
set abc.&names;
run;

 

Error : 

 

SYMBOLGEN: Macro variable NAMES resolves to WORK1WORK2WORK3
180 set abc.&names;
ERROR: File ABC.WORK1WORK2WORK3.DATA does not exist.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

It should be 

 

     select catx('.', 'abc', memname) into :names separated by ' ' 

 

Your currently generating a macro variable that looks like: 

 

Work1 Work2 Work3

 

You need to create 

abc.work1 abc.work2 etc...

 

You have a spelling mistake in your PROC SQL and are missing the library portion of the name. 

 

If they all have the same prefix you can use the colon shortcut instead. 

 

Data want;

set abc.work:;

run;

View solution in original post

3 REPLIES 3
Reeza
Super User

It should be 

 

     select catx('.', 'abc', memname) into :names separated by ' ' 

 

Your currently generating a macro variable that looks like: 

 

Work1 Work2 Work3

 

You need to create 

abc.work1 abc.work2 etc...

 

You have a spelling mistake in your PROC SQL and are missing the library portion of the name. 

 

If they all have the same prefix you can use the colon shortcut instead. 

 

Data want;

set abc.work:;

run;

atul_desh
Quartz | Level 8

I've corrected the line "seprated by ' '

 

but now i'm not getting why work1, work2 & work3 are searching in work library. I've given abc.&names

 

Code : 

 

libname abc 'C:\Users\Sony\Desktop\datasets';
OPTIONS SYMBOLGEN;

proc sql noprint;
select memname into: names seprated by ' '
from Dictionary.tables
where libname="ABC" ;
quit;

data want;
set abc.&names;
run;

 

 

Error : 

SYMBOLGEN: Macro variable NAMES resolves to WORK1 WORK2 WORK3
360 set abc.&names;
ERROR: File WORK.WORK2.DATA does not exist.
ERROR: File WORK.WORK3.DATA does not exist.

monikka1991
Obsidian | Level 7

Still you need to add the function catx('.', 'abc', memname) which will append each of the datasets name with the library abc .

 

Thanks,

Monika

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 2713 views
  • 3 likes
  • 3 in conversation