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;
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: