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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

 

 

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;

 

View solution in original post

5 REPLIES 5
Reeza
Super User

 

 

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;

 

Elliott
Obsidian | Level 7

Thanks!

Elliott
Obsidian | Level 7

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

Elliott
Obsidian | Level 7
Thanks! I figured that out after I sent the message.


SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2196 views
  • 2 likes
  • 2 in conversation