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

 

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

The data step should be

 

data ia.literacy2;
	set ia.literacy;
	tot_jaundice + jaundice;
	keep Subject jaundice tot_jaundice;
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

The data step should be

 

data ia.literacy2;
	set ia.literacy;
	tot_jaundice + jaundice;
	keep Subject jaundice tot_jaundice;
run;
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

 

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;

 

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13
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;

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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
  • 3 replies
  • 1818 views
  • 1 like
  • 3 in conversation