BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aljosa
Fluorite | Level 6

Hi all,

I have a column named ID filled out like this (with blancs):

data have;
input ID $;
infile datalines missover;
datalines;
1       
2      
3


4
5       
 
;

I would like to fill out all blancs with the last value populated, so the column I want would look like this:

data want;
input ID $;
infile datalines missover;
datalines;
1       
2
3
3
3
4
5
5
; 

Thank you for your help. Kind regards

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @Aljosa 

 

Here is one approach to achieve this:

data want;
	set have;
	retain _ID;
	if not missing(ID) then _ID = ID;
	drop ID;
	rename _ID = ID;
run;

Best,

View solution in original post

1 REPLY 1
ed_sas_member
Meteorite | Level 14

Hi @Aljosa 

 

Here is one approach to achieve this:

data want;
	set have;
	retain _ID;
	if not missing(ID) then _ID = ID;
	drop ID;
	rename _ID = ID;
run;

Best,

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 238 views
  • 1 like
  • 2 in conversation