BookmarkSubscribeRSS Feed
SeanG008
Calcite | Level 5

Hi,

I am new to SAS and I need to know how to limit the number of months to 24.

Every month I upload new data and would like the oldest month to be dropped off.

Any advice?

4 REPLIES 4
data_null__
Jade | Level 19

Are you talking about data sets, variables, or observations?  Show some example data.

SeanG008
Calcite | Level 5

Months are variables in the data

data_null__
Jade | Level 19

Depends on how the month variables are named.  Here is an example that might be helpful.

data new;
   m1=1;
  
label m1='New m1';
  
run;
data m24;
   array m[24] (1:24);
   run;

data m24u;
   merge new m24(drop=m24 rename=(m1-m23=x2-x24 x2-x24=m2-m24));
   run;

9-10-2014 3-01-00 PM.pngproc contents varnum;
  
run;
Hima
Obsidian | Level 7

data have;
input id date;
format date mmddyy10.;
informat date mmddyy10.;
cards;
1 01/01/2014
2 01/01/2013
3 01/01/2012
;
run;

data want;
set have;
var1=INTCK('Month',date,today());
if INTCK('Month',date,today()) ge 24 then delete;
else output;
run;

proc print; run;

Capture.JPG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 901 views
  • 0 likes
  • 3 in conversation