proc contents data = ia.literacy;
run;
proc sort data=ia.literacy out=sort_literacy;
by Subject;
run;
data ia.literacy2;
set ia.literacy;
tot_jaundice + jaundice;
keep Subject id jaundice tot_jaundice;
run;
WARNING: The variable id in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 50 observations read from the data set IA.LITERACY.
NOTE: The data set IA.LITERACY2 has 50 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
This is instruction that I got
a. Use the literacy data set. Run proc contents and see what variables are in the data set. Sort the data by Subject number.
b. Determine the number of subjects that correctly read the word jaundice by creating an accumulation variable. The variable jaundice will have the value of 1 for these subjects if correct, 0 otherwise. Create a temporary dataset and keep just the Subject id, jaundice and the accumulation variable that you create. Use proc means to check that the last observations is the sum of the jaundice variable.
and I have trouble with solving b.
could you help me with this please?
Thank you
The data step should be
data ia.literacy2;
set ia.literacy;
tot_jaundice + jaundice;
keep Subject jaundice tot_jaundice;
run;
The data step should be
data ia.literacy2;
set ia.literacy;
tot_jaundice + jaundice;
keep Subject jaundice tot_jaundice;
run;
proc contents data = ia.literacy;
run;
proc sort data=ia.literacy out=sort_literacy;
by Subject;
run;
data ia.literacy2(keep Subject id jaundice tot_jaundice);
set ia.literacy;
by subject;
if first.subject then tot_jaundice =0;
tot_jaundice + jaundice;
if last.subject then output;
run;
data ia.literacy2;
retain tot_jaundice 0;
set ia.literacy;
by subject;
if first.subject then tot_jaunice = 0;
tot_jaundice + jaundice;
if last.subject then output;
keep Subject id jaundice tot_jaundice;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.