Hi, I have about 10 vars that are scattered in between a date period from 1990.01 to 2011.12.. But some vars start latter than others and some end sooner than others. Is there a way I can check for each var when the max and min dates are... the caveat is that in between there may be some values missing for certain vars.
So something like this:
Have
Date Var1 Var2 Var3 Var4
1990.01 34 . 43 .
1990.02 33 . 56 68
1990.03 36 12 . 78
1990.04 37 34 . .
1990.05 32 . 24 .
I would see
Var1 (MIN=1990.01 and Max=1990.05),
Var2 (MIN=1990.03 and MAX=1990.04),
Var3 (MIN=1990.01 and MAX=1990.05),
Var4 (MIN=1990.02 and Max=1990.03)
Thanks
Hello -
If you have access to SAS/ETS software, you might want to consider running PROC TIMESERIES.
Regards,
Udo
data have;
input Date YYMMN6. var1 var2 var3 var4;
format date date9.;
cards;
199001 34 . 43 .
199002 33 . 56 68
199003 36 12 . 78
199004 37 34 . .
199005 32 . 24 .
;
proc timeseries data=have out=_null_ outsum=want(keep=_name_ start end);
id date interval=month accumulate=total;
var var1-var4;
run;
Hello -
If you have access to SAS/ETS software, you might want to consider running PROC TIMESERIES.
Regards,
Udo
data have;
input Date YYMMN6. var1 var2 var3 var4;
format date date9.;
cards;
199001 34 . 43 .
199002 33 . 56 68
199003 36 12 . 78
199004 37 34 . .
199005 32 . 24 .
;
proc timeseries data=have out=_null_ outsum=want(keep=_name_ start end);
id date interval=month accumulate=total;
var var1-var4;
run;
Thanks Udo .. worked perfectly...
Well, you apparently do have ets. If you didn't, you could have used:
data have;
informat date date9.;
format date date9.;
input date var1-var4;
cards;
01jan1990 34 . 43 .
01feb1990 33 . 56 68
01mar1990 36 12 . 78
01apr1990 37 34 . .
01may1990 32 . 24 .
;
data want (keep=mindates: maxdates:);
set have end=eof;
array vars(*) var1-var4;
array mindates(4);
array maxdates(4);
format mindates: maxdates: date9.;
retain mindates: maxdates:;
do i=1 to dim(vars);
if missing(mindates(i)) and not missing(vars(i))
then mindates(i)=date;
if not missing(vars(i)) then maxdates(i)=date;
end;
if eof then output;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.