BookmarkSubscribeRSS Feed
teja5959
Fluorite | Level 6

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

4 REPLIES 4
teja5959
Fluorite | Level 6

it's not working

Kurt_Bremser
Super User

@teja5959 wrote:

it's not working


This is an extremely unhelpful statement. You'd be pissed if @RW9 just answered "It's working", and nothing else, eh?

 

So post your code and your log, and where the result differs from your expectations, so we can test what's "not working".

Ksharp
Super User
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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 778 views
  • 0 likes
  • 4 in conversation