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).
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: