this is the real data
data test;
input rank_no rankdate eq;
cards;
1 19880331 .
1 19880630 .
1 19880930 .
1 19881231 .
1 19890331 .
1 19890630 .
1 19890930 .
1 19891231 .
1 19900331 .
1 19900630 .
1 19900930 .
1 19901231 39.2
1 19910331 .
1 19910630 .
1 19910930 .
1 19911231 127.336
1 19920331 .
1 19920630 .
1 19920930 .
1 19921231 252.952
1 19930331 .
1 19930630 .
1 19930930 .
1 19931231 209.567
1 19940331 .
1 19940630 .
1 19940930 .
1 19941231 239.622
1 19950331 .
1 19950630 .
1 19950930 .
1 19951231 265.222
1 19960331 .
1 19960630 .
1 19960930 .
1 19961231 458.352
1 19970331 .
1 19970630 .
1 19970930 .
1 19971231 881.127
1 19980331 .
1 19980630 .
1 19980930 .
1 19981231 1752.1
1 19990331 .
1 19990630 .
1 19990930 .
1 19991231 2298.734
1 20000331 .
1 20000630 .
2 19911231 .
2 19920331 .
2 19920630 .
2 19920930 .
2 19921231 .
2 19930331 .
2 19930630 .
2 19930930 .
2 19931231 .
2 19940331 .
2 19940630 .
2 19940930 .
2 19941231 2.792
2 19950331 .
2 19950630 .
2 19950930 .
2 19951231 2.795
2 19960331 .
2 19960630 .
2 19960930 .
2 19961231 8.635
2 19970331 .
2 19970630 .
2 19970930 .
2 19971231 20.477
2 19980331 .
2 19980630 .
2 19980930 .
2 19981231 48.377
2 19990331 .
2 19990630 .
2 19990930 .
2 19991231 56.088
;
run;
I try to change the chrac to numeric but it does not work
data test;
input id rankdate eq;
cards;
1 19880331 .
1 19880630 .
1 19880930 .
1 19881231 .
1 19890331 .
1 19890630 .
1 19890930 .
1 19891231 .
1 19900331 .
1 19900630 .
1 19900930 .
1 19901231 39.2
1 19910331 .
1 19910630 .
1 19910930 .
1 19911231 127.336
1 19920331 .
1 19920630 .
1 19920930 .
1 19921231 252.952
1 19930331 .
1 19930630 .
1 19930930 .
1 19931231 209.567
1 19940331 .
1 19940630 .
1 19940930 .
1 19941231 239.622
1 19950331 .
1 19950630 .
1 19950930 .
1 19951231 265.222
1 19960331 .
1 19960630 .
1 19960930 .
1 19961231 458.352
1 19970331 .
1 19970630 .
1 19970930 .
1 19971231 881.127
1 19980331 .
1 19980630 .
1 19980930 .
1 19981231 1752.1
1 19990331 .
1 19990630 .
1 19990930 .
1 19991231 2298.734
1 20000331 .
1 20000630 .
2 19911231 .
2 19920331 .
2 19920630 .
2 19920930 .
2 19921231 .
2 19930331 .
2 19930630 .
2 19930930 .
2 19931231 .
2 19940331 .
2 19940630 .
2 19940930 .
2 19941231 2.792
2 19950331 .
2 19950630 .
2 19950930 .
2 19951231 2.795
2 19960331 .
2 19960630 .
2 19960930 .
2 19961231 8.635
2 19970331 .
2 19970630 .
2 19970930 .
2 19971231 20.477
2 19980331 .
2 19980630 .
2 19980930 .
2 19981231 48.377
2 19990331 .
2 19990630 .
2 19990930 .
2 19991231 56.088
;
run;
data want ;
set test ;
array _char eq ;
array _num 8 eq1;
do i=1 to dim(_char);
_num(i) = input(_char(i),best32.);
end;
drop eq1 i;
run;
data want1;
set want;
by ID;
retain lstv;
If first.ID then lstv = "";
if EQ ne "" then lstv=EQ;
if EQ="" then EQ=lstv;
run;
Numeric missing is a period.
Character missing is a 'blank' or 'space'.
Look at how my code checks for missing versus what youre using.
I'm 99% sure my code is correct given your new data.
Or switch to the MISSING function, which handles either.
If missing(eq) then ...
How can I change year+1 in your program
data test;
input id rankdate eq;
cards;
1 19880331 .
1 19880630 .
1 19880930 .
1 19881231 .
1 19890331 .
1 19890630 .
1 19890930 .
1 19891231 .
1 19900331 .
1 19900630 .
1 19900930 .
1 19901231 39.2
1 19910331 .
1 19910630 .
1 19910930 .
1 19911231 127.336
1 19920331 .
1 19920630 .
1 19920930 .
1 19921231 252.952
1 19930331 .
1 19930630 .
1 19930930 .
1 19931231 209.567
1 19940331 .
1 19940630 .
1 19940930 .
1 19941231 239.622
1 19950331 .
1 19950630 .
1 19950930 .
1 19951231 265.222
1 19960331 .
1 19960630 .
1 19960930 .
1 19961231 458.352
1 19970331 .
1 19970630 .
1 19970930 .
1 19971231 881.127
1 19980331 .
1 19980630 .
1 19980930 .
1 19981231 1752.1
1 19990331 .
1 19990630 .
1 19990930 .
1 19991231 2298.734
1 20000331 .
1 20000630 .
2 19911231 .
2 19920331 .
2 19920630 .
2 19920930 .
2 19921231 .
2 19930331 .
2 19930630 .
2 19930930 .
2 19931231 .
2 19940331 .
2 19940630 .
2 19940930 .
2 19941231 2.792
2 19950331 .
2 19950630 .
2 19950930 .
2 19951231 2.795
2 19960331 .
2 19960630 .
2 19960930 .
2 19961231 8.635
2 19970331 .
2 19970630 .
2 19970930 .
2 19971231 20.477
2 19980331 .
2 19980630 .
2 19980930 .
2 19981231 48.377
2 19990331 .
2 19990630 .
2 19990930 .
2 19991231 56.088
;
run;
Data want1;
Set test;
By Id; retain new_EQ;
if missing(eq) then new_eq = eq;
else if last.id then Do; next(rankdate); output;
Output;
run;
can anyone help me????
We answered your question.
My initial answer minus the DO/OUTPUT sections because you're not actually repeating any observations. You're only doing Last Obs Carried Forward. You can search that term with SAS if you want further solutions.
Data want;
Set have;
By Id;
Retain new_eq;
If first.id then new_eq = eq;
If not missing(eq) then new_eq = eq;
run;
You can also look at PROC TIMESERIES.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.