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
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
data test2; set test;
by sub;
if not first.sub then do;bmi=.; age=.; end;
run;
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.