DATA Step, Macro, Functions and more

Append monthly datasets

Accepted Solution Solved
Reply
Contributor
Posts: 37
Accepted Solution

Append monthly datasets

[ Edited ]

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. 

 

 


Accepted Solutions
Solution
‎02-27-2018 06:42 PM
Trusted Advisor
Posts: 1,387

Re: Append monthly datasets

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

 

View solution in original post


All Replies
Esteemed Advisor
Posts: 5,611

Re: Append monthly datasets

data allData;
set test.monthly_data_201: ;
run;

(untested)

 

PG
Solution
‎02-27-2018 06:42 PM
Trusted Advisor
Posts: 1,387

Re: Append monthly datasets

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

 

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 175 views
  • 1 like
  • 3 in conversation