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

i have monthly customer status datasets which need to be compiled together to create a time series of customer information. Any idea how i can use a macro to call in the datasets. These datasets are in a separate library (lets say lib = test). i need them in the work library. The datasets are named as monthly_data_201203. The datasets start from 201301 till 201801. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

The program:

 

data monthly_data_all;
  set monthly_data_20:   open=defer;
run;

will read in all data sets whose name begins with MONTHLY_DATA_20.   The data sets will be read in lexicographic order, which in your case will correspond to chronological order.  Assuming all the data sets have the same variables, you can also use the "open=defer" option which tells sas to re-use the same input/output buffer in memory for all the data sets, instead of creating a buffer for each incoming data set (i.e. about 61 buffers for 61 datasets for covering months).

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21
data allData;
set test.monthly_data_201: ;
run;

(untested)

 

PG
mkeintz
PROC Star

The program:

 

data monthly_data_all;
  set monthly_data_20:   open=defer;
run;

will read in all data sets whose name begins with MONTHLY_DATA_20.   The data sets will be read in lexicographic order, which in your case will correspond to chronological order.  Assuming all the data sets have the same variables, you can also use the "open=defer" option which tells sas to re-use the same input/output buffer in memory for all the data sets, instead of creating a buffer for each incoming data set (i.e. about 61 buffers for 61 datasets for covering months).

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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
  • 2 replies
  • 1227 views
  • 1 like
  • 3 in conversation