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

Hi Everyone, thank you for reading the post. 

 

I combined 24 datasets using the following code: 


data conso.agloan;
set conso.agloan1993 conso.agloan1994 conso.agloan1995 conso.agloan1996 conso.agloan1997 conso.agloan1998 conso.agloan1999 conso.agloan2000 conso.agloan2001 conso.agloan2002 conso.agloan2003 conso.agloan2004 conso.agloan2005 conso.agloan2006 conso.agloan2007 conso.agloan2008 conso.agloan2009 conso.agloan2010 conso.agloan2011 conso.agloan2012 conso.agloan2013 conso.agloan2014 conso.agloan2015 conso.agloan2016;
run;

 

It works. But is there any trick to do it smarter without actually typing each dataset, something like

 

data conso.agloan;

set conso.agloan1993 - conso.agloan2016;

run;

 

Thank you in advance. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Or if you want ALL of the agloan sets in the library:

 

data conso.agloan;

set conso.agloan: ; /* note the : that indicates the list operator */

run;

 

If your individual sets are largish there may be a time penalty due to the way SET works and a series of Proc Append Calls may be quicker to execute. Unfortunately Proc Append only uses two data sets and not the shortcut list.

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

did your something like 

 

data conso.agloan;

set conso.agloan1993 - conso.agloan2016;

run;

 

work?????

changxuosu1
Obsidian | Level 7
oh my God! it works!!! it's so hilarious.. 🙂 thanks!
ballardw
Super User

Or if you want ALL of the agloan sets in the library:

 

data conso.agloan;

set conso.agloan: ; /* note the : that indicates the list operator */

run;

 

If your individual sets are largish there may be a time penalty due to the way SET works and a series of Proc Append Calls may be quicker to execute. Unfortunately Proc Append only uses two data sets and not the shortcut list.

changxuosu1
Obsidian | Level 7
Thank you ballardw! it works perfectly!
SuryaKiran
Meteorite | Level 14

If all the tables are in specific library and have a defined prefix or suffix then you can get those table list by running query on dictionary.tables

proc sql;
select distinct memname into: SET_Tables separated by " "
	from dictionary.tables
	where libname="CONSO" and memname like 'AGLOAN%';
quit;
data want;
set &SET_Tables;
run;
Thanks,
Suryakiran
changxuosu1
Obsidian | Level 7
Thank you so much Suryakiran~ It works great~
changxuosu1
Obsidian | Level 7
can i choose two solutions? this works great as well. ( I changed select distinct memname into 'conso.'||left(memname) to customize to my libary)

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