@Giovani wrote:
I am looking to create a new variable matching each line in the variable Month with a corresponding line in the new variable Season with a label of winter, fall, summer, or spring.
Thanks
Did you try applying the format created? See the full example below.
*Create a format;
data ctrl;
fmtname='Seasons';
format start end date9.;
do i=0 by 1;
start =intnx('month','01jan1960'd,i*3,'b');
end =intnx('month',start,2,'e');
select(month(start));
when(12,1,2) label='Winter';
when(3,4,5) label='Spring';
when(6,7,8) label='Summer';
when(9,10,11) label='Fall';
otherwise;
end;
output;
if start > intnx('year',today(),5,'e') then leave;
end;
run;
proc format cntlin=ctrl;
run;
*demo application of format;
data want;
format date date9. date_formatted seasons.;
do date='01Jan2016'd to '31Dec2017'd;
date_formatted = date;
date_char =put(date, seasons.);
output;
end;
run;
... View more