Hi how to do locf in this way.
data val1;
input visit $10. value ;
cards;
Week 2 1.5
Week 4 2.3
Week 8 3.2
run;
how to get this output.
VISIT VALUE
Week 2 1.5
Week 4 2.3
Week 6 2.3
Week 8 3.2
Week 10 3.2
Week 12 3.2
Much the same as your other question:
https://communities.sas.com/t5/Base-SAS-Programming/visitnum-carry-forward-locf/m-p/468307
it's not working
data val1;
input visit & $10. value ;
cards;
Week 2 1.5
Week 4 2.3
Week 8 3.2
;
run;
data want;
merge val1 val1(firstobs=2 keep=visit rename=(visit=_visit)) end=last;
array x{6} $32 _temporary_ ('Week 2' 'Week 4' 'Week 6' 'Week 8' 'Week 10' 'Week 12');
output;
do i=whichc(visit,of x{*})+1 to ifn(last,6,whichc(_visit,of x{*})-1);
visit=x{i};output;
end;
drop i _visit;
run;
proc print;run;
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.
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.