## Summary report

Solved
Occasional Contributor
Posts: 14

# Summary report

Hi everyone,

I am fairly new to SAS and need your help. I have a dataset of school children with grades and food habits. Food habit section has five variables. each variable tells the no. of time one particular food is take. For example,

 ID Grade Food A Food B Food C Food D 101 7 Yes No Yes Yes 102 8 No No No Yes 103 7 Yes Yes No Yes

How can I make a table showing grade and food food habit?

 Frequency Grade 7 Yes 6 No 2 Grade 8 Yes 1 No 3

Thank you.

Khalid

Accepted Solutions
Solution
‎11-02-2015 09:51 AM
Posts: 1,270

## Re: Summary report

Try this to generate desired output:

data have;
input ID Grade FoodA \$ FoodB \$ FoodC \$ FoodD \$;
datalines;
101 7 Yes No Yes Yes
102 8 No No No Yes
103 7 Yes Yes No Yes
;

proc transpose data=have out=want;
var FoodA FoodB FoodC FoodD;
run;

proc tabulate data=want;
run;

All Replies
Super User
Posts: 13,542

## Re: Summary report

One way

``````proc tabulate data=have;
class grade fooda foodb foodc foodd;
table
n
;
run;``````

this does all the foods at once. Grade * fooda , n ; would do just fooda.

Occasional Contributor
Posts: 14

## Re: Summary report

@ballardw,
Thank you ... Will get back to you soon.

Happy Halloweens!
Solution
‎11-02-2015 09:51 AM
Posts: 1,270

## Re: Summary report

Try this to generate desired output:

data have;
input ID Grade FoodA \$ FoodB \$ FoodC \$ FoodD \$;
datalines;
101 7 Yes No Yes Yes
102 8 No No No Yes
103 7 Yes Yes No Yes
;

proc transpose data=have out=want;
var FoodA FoodB FoodC FoodD;
run;

proc tabulate data=want;
run;

Occasional Contributor
Posts: 14

## Re: Summary report

Thank you so much

It worked perfectly.
🔒 This topic is solved and locked.