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

Hi,

I've a dataset similar to below. I want to assign the Group by value to individual records as shown below.

 

NameSex
AliceF
Barbara 
Carol 
Jane 
Janet 
Joyce 
Judy 
Louise 
Mary 
AlfredM
Henry 
James 
Jeffrey 
John 
Philip 
Robert 
Ronald 
Thomas 
William

 

 

desired output

 

NameSex
AliceF
BarbaraF
CarolF
JaneF
JanetF
JoyceF
JudyF
LouiseF
MaryF
AlfredM
HenryM
JamesM
JeffreyM
JohnM
PhilipM
RobertM
RonaldM
ThomasM
WilliamM
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
infile cards truncover;
input (Name	Sex) ($);
cards;
Alice	F
Barbara	 
Carol	 
Jane	 
Janet	 
Joyce	 
Judy	 
Louise	 
Mary	 
Alfred	M
Henry	 
James	 
Jeffrey	 
John	 
Philip	 
Robert	 
Ronald	 
Thomas	 
William	
;
 
data want;
set have;
retain _s;
if missing(sex) then sex=_s;
else _s=sex;
drop _s;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20
data have;
infile cards truncover;
input (Name	Sex) ($);
cards;
Alice	F
Barbara	 
Carol	 
Jane	 
Janet	 
Joyce	 
Judy	 
Louise	 
Mary	 
Alfred	M
Henry	 
James	 
Jeffrey	 
John	 
Philip	 
Robert	 
Ronald	 
Thomas	 
William	
;
 
data want;
set have;
retain _s;
if missing(sex) then sex=_s;
else _s=sex;
drop _s;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 648 views
  • 0 likes
  • 2 in conversation