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

Hello all, 

I am struggling on a simple program. I wanted to assign missing values for all the BMI and age that have duplicate records.

 

 

data test;
input  sub bmi age med$;
datalines;
1 0.2 12 ibuprofen
1 0.2 12 crocin
1 0.2 12 cetrizine
2 0.3 14 rituxim
2 0.3 14 belimu
;

 

 

My output data set should have multiple records for subject ID but missing values for BMI and age that are duplicates. My output should look like below.Thanks for your help. 

 

1 0.2 12 ibuprofen
1   .  . crocin
1   .  . cetrizine
2 0.3 14 rituxim
2   .  . belimu

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Depends upon what you consider duplicates. Possibly you're looking for something like:

data test;
input  sub bmi age med$;
datalines;
1 0.2 12 ibuprofen
1 0.2 12 crocin
1 0.2 12 cetrizine
2 0.3 14 rituxim
2 0.3 14 belimu
;

data test2;
  set test;
  by sub bmi age;
  if not first.age then do;
    call missing(bmi);
    call missing(age);
  end;
run;

Art, CEO, AnalystFinder.com

 

 

View solution in original post

2 REPLIES 2
tomrvincent
Rhodochrosite | Level 12

data test2; set test;
by sub;
if not first.sub then do;bmi=.; age=.; end;
run;

art297
Opal | Level 21

Depends upon what you consider duplicates. Possibly you're looking for something like:

data test;
input  sub bmi age med$;
datalines;
1 0.2 12 ibuprofen
1 0.2 12 crocin
1 0.2 12 cetrizine
2 0.3 14 rituxim
2 0.3 14 belimu
;

data test2;
  set test;
  by sub bmi age;
  if not first.age then do;
    call missing(bmi);
    call missing(age);
  end;
run;

Art, CEO, AnalystFinder.com

 

 

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
  • 2 replies
  • 1123 views
  • 2 likes
  • 3 in conversation