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.
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).
data allData;
set test.monthly_data_201: ;
run;
(untested)
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).
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.
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.