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
data literacy3;
	set ia.literacy;
	tot_jaundice + jaundice;
	tot_anemia + anemia;
	total = 0
	if anemia =1 and jaundice = 1 
	then total = total +1;
	keep Subject jaundice tot_jaundice tot_anemia anemia total;
run;

This is the code that I ran, and I got a result of 

 

SAS Output

Obs Subject Jaundice Anemia tot_jaundice tot_anemia total
11111.
20112.
31123.
41134.
51145.
60146.
71157.
81168.
90068.
101179.
1111810.
1211911.
1301912.
14111013.
15101113.
16111214.
17111315.
18011316.
19111417.
20001417.
21111518.
22111619.
23111720.
24011721.
25111822.
26111923.
27011924.
28112025.
29112126.
30112227.
31112328.
32112429.
33112530.
34002530.
35112631.
36112732.
37112833.
38112934.
39113035.
40113136.
41003136.
42113237.
43113338.
44003338.
45113439.
46013440.
47113541.
48103641.
49113742.
50003742.
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@minsung wrote:

This is an instruction for the problem. Hope it helps 

 

Now create another temporary data set using the same literacy data set. This time create two variables, first an accumulation variable that accumulates the number of subjects that could read the word jaundice. Accumulate a second variable associated with anemia (subjects that could read the word anemia). Make a third variable that accumulate when both are correct. What is the total number of people who could read the two words correctly


Well, I suppose I could get picky and say "accumulate what" when both are correct? 

 

Nevertheless, assuming it means "create the  cumulative count of the number of times both are correct" (does that sound right to you?) then try replacing the line in your program with this corrected line:

 

if anemia =1 and jaundice = 1 then total+1;
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

For us to help you, you would have to explain and show us the desired output. 

--
Paige Miller
minsung
Fluorite | Level 6

This is an instruction for the problem. Hope it helps 

 

Now create another temporary data set using the same literacy data set. This time create two variables, first an accumulation variable that accumulates the number of subjects that could read the word jaundice. Accumulate a second variable associated with anemia (subjects that could read the word anemia). Make a third variable that accumulate when both are correct. What is the total number of people who could read the two words correctly

ballardw
Super User

Without actual input example data of your ia.literacy data set I am guessing somewhat. You might want to take a look at the results  of this code.

proc summary data=ia.literacy;
   class anemia jaundice;
   output out=literacysummary;
run;

The output set will have a variable named _freq_ which counts cases of values. There will also be a variable _type_ that indicates which combinations of the class variables are being considered. This will give counts of overall records, possibly not very useful, each level of the variables anemia and jaundice separately and counts of the levels of anemia and jaundice combined. I suspect that _type_ values of 1, 2 and 3 will provide some of the values you want.

 

PaigeMiller
Diamond | Level 26

@minsung wrote:

This is an instruction for the problem. Hope it helps 

 

Now create another temporary data set using the same literacy data set. This time create two variables, first an accumulation variable that accumulates the number of subjects that could read the word jaundice. Accumulate a second variable associated with anemia (subjects that could read the word anemia). Make a third variable that accumulate when both are correct. What is the total number of people who could read the two words correctly


Well, I suppose I could get picky and say "accumulate what" when both are correct? 

 

Nevertheless, assuming it means "create the  cumulative count of the number of times both are correct" (does that sound right to you?) then try replacing the line in your program with this corrected line:

 

if anemia =1 and jaundice = 1 then total+1;
--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 768 views
  • 1 like
  • 3 in conversation