BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
AMFR
Quartz | Level 8

Hi everyone,

 

I have a dataset in the first table and i have to retain values from the previous row to blank rows. How can i do that? Thanks in advance

IdentifierDateNPO_OrderNPO_OrderedInstant
1122/2/2023NPO DIET02FEB23:22:48:00
1122/3/2023 .
1122/4/2023NPO DIET04FEB23:07:24:00
1122/5/2023 .
1122/6/2023DIET TUBE FEEDING ONLY (NPO)06FEB23:06:43:00
1122/6/2023DIET TUBE FEEDING ONLY (NPO)06FEB23:07:52:00
1122/7/2023NPO DIET07FEB23:17:06:00
1122/8/2023 .
1122/9/2023 .
1122/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:09:41:00
1132/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:09:54:00
1132/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:10:27:00
1132/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:10:27:00
1132/10/2023NPO DIET10FEB23:13:48:00
1132/11/2023  
1132/12/2023 .
1132/13/2023DIET TUBE FEEDING ONLY (NPO)13FEB23:09:14:00
1132/14/2023 .
1132/15/2023DIET TUBE FEEDING ONLY (NPO)15FEB23:09:44:00
1132/16/2023DIET TUBE FEEDING ONLY (NPO)16FEB23:08:46:00
1132/17/2023DIET TUBE FEEDING ONLY (NPO)17FEB23:10:06:00
1132/18/2023DIET TUBE FEEDING ONLY (NPO)18FEB23:07:59:00

 

IdentifierDateNPO_OrderNPO_OrderedInstant
1122/2/2023NPO DIET02FEB23:22:48:00
1122/3/2023NPO DIET02FEB23:22:48:00
1122/4/2023NPO DIET04FEB23:07:24:00
1122/5/2023NPO DIET04FEB23:07:24:00
1122/6/2023DIET TUBE FEEDING ONLY (NPO)06FEB23:06:43:00
1122/6/2023DIET TUBE FEEDING ONLY (NPO)06FEB23:07:52:00
1122/7/2023NPO DIET07FEB23:17:06:00
1122/8/2023NPO DIET07FEB23:17:06:00
1122/9/2023NPO DIET07FEB23:17:06:00
1122/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:09:41:00
1132/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:09:54:00
1132/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:10:27:00
1132/10/2023DIET TUBE FEEDING ONLY (NPO)10FEB23:10:27:00
1132/10/2023NPO DIET10FEB23:13:48:00
1132/11/2023NPO DIET10FEB23:13:48:00
1132/12/2023NPO DIET10FEB23:13:48:00
1132/13/2023DIET TUBE FEEDING ONLY (NPO)13FEB23:09:14:00
1132/14/2023DIET TUBE FEEDING ONLY (NPO)13FEB23:09:14:00
1132/15/2023DIET TUBE FEEDING ONLY (NPO)15FEB23:09:44:00
1132/16/2023DIET TUBE FEEDING ONLY (NPO)16FEB23:08:46:00
1132/17/2023DIET TUBE FEEDING ONLY (NPO)17FEB23:10:06:00
1132/18/2023DIET TUBE FEEDING ONLY (NPO)18FEB23:07:59:00
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Please help us by modifying the subject on your original message to "Retain values down columns"

 

data want;
    set have;
    retain npo_orderedinstant1;
    if not missing(npo_orderedinstant) then npo_orderedinstant1=npo_orderedinstant;
run;

 

You can do the same thing for variable npo_order, so I leave that as a homework assignment for you.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Please help us by modifying the subject on your original message to "Retain values down columns"

 

data want;
    set have;
    retain npo_orderedinstant1;
    if not missing(npo_orderedinstant) then npo_orderedinstant1=npo_orderedinstant;
run;

 

You can do the same thing for variable npo_order, so I leave that as a homework assignment for you.

--
Paige Miller
AMFR
Quartz | Level 8
Thank you very much, highly appreciate it.

And I will fix the subject
Tom
Super User Tom
Super User

Search for methods to implement Last Observation Carried Forward (LOCF).

 

You can normally do this very easily by using the UPDATE statement to treat the data as a series of transactions.  Include an OUTPUT statement to preserve the individual observations instead of just the final result of applying all of the transactions.

data want;
  update have(obs=0) have;
  by identifier;
  output;
run;
AMFR
Quartz | Level 8

Thank you, i will look into that

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 902 views
  • 0 likes
  • 3 in conversation