DATA Step, Macro, Functions and more

Set All Datasets present in library into one dataset

Accepted Solution Solved
Reply
Contributor
Posts: 65
Accepted Solution

Set All Datasets present in library into one dataset

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.


Accepted Solutions
Solution
‎11-14-2016 01:57 AM
Super User
Posts: 19,850

Re: Set All Datasets present in library into one dataset

[ Edited ]
Posted in reply to atul_desh

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


All Replies
Solution
‎11-14-2016 01:57 AM
Super User
Posts: 19,850

Re: Set All Datasets present in library into one dataset

[ Edited ]
Posted in reply to atul_desh

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;

Contributor
Posts: 65

Re: Set All Datasets present in library into one dataset

Posted in reply to atul_desh

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.

Occasional Contributor
Posts: 8

Re: Set All Datasets present in library into one dataset

Posted in reply to atul_desh

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

 

Thanks,

Monika

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 281 views
  • 2 likes
  • 3 in conversation