I have a process where I create a daily dataset from a large text file. At the beginning of the next month I need to append the daily data from the previous month into a monthly dataset.
Can this be automated so that I don't have to manually create the monthly dataset. Can the automation account for leap year and number of days in a month to pick up all files?
this is my code now:
libname us "/ptr/us_bds/";
data us.bds_call_lvl_201802; /* creating the monthly file for all the daily files */
set us.bds_call_lvl_20180201
us.bds_call_lvl_20180202
us.bds_call_lvl_20180203
us.bds_call_lvl_20180204
us.bds_call_lvl_20180205
us.bds_call_lvl_20180206
us.bds_call_lvl_20180207
us.bds_call_lvl_20180208
us.bds_call_lvl_20180209
us.bds_call_lvl_20180210
us.bds_call_lvl_20180211
us.bds_call_lvl_20180212
us.bds_call_lvl_20180213
us.bds_call_lvl_20180214
us.bds_call_lvl_20180215
us.bds_call_lvl_20180216
us.bds_call_lvl_20180217
us.bds_call_lvl_20180218
us.bds_call_lvl_20180219
us.bds_call_lvl_20180220
us.bds_call_lvl_20180221
us.bds_call_lvl_20180222
us.bds_call_lvl_20180223
us.bds_call_lvl_20180224
us.bds_call_lvl_20180225
us.bds_call_lvl_20180226
us.bds_call_lvl_20180227
us.bds_call_lvl_20180228
;
run;
Thanks, any assistance you can provide will be greatly appreciated.
Elliott
You can make a macro variable for the 201802 portion if desired.
untested, note the colon in the data step.
%let period = %sysfunc(intnx(month, %sysfunc(today()), -1, b), yymm6.);
data us.bds_call_lvl_. /* creating the monthly file for all the daily files */
set us.bds_call_lvl_&period.: ;
run;
You can make a macro variable for the 201802 portion if desired.
untested, note the colon in the data step.
%let period = %sysfunc(intnx(month, %sysfunc(today()), -1, b), yymm6.);
data us.bds_call_lvl_. /* creating the monthly file for all the daily files */
set us.bds_call_lvl_&period.: ;
run;
Thanks!
I tried this but the result comes out to be 18M02. I have tried to edit
%let period = %sysfunc(intnx(month, %sysfunc(today()), -1, b), yymm6.);
but have not been able to get the date to come out as YYYYMM format.
Thank you
Try yymmN6.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.