I have the following code to create a report for a given data:
data cutepets;
length pet $20;
input gender $ pet $ number_of_pets;
cards;
boy cockatiel 1
boy turtle 3
boy rabbit 4
girl cockatiel 2
girl turtle 3
girl rabbit 7
;
run;
title "Number of Cute Pets Owned by Families of 3rd Graders";
proc tabulate data=cutepets style=[just=center];
class gender pet;
var number_of_pets;
table gender='Gender',
pet='Pet' * number_of_pets='# of Pets' * sum=' ' /
box=' ' misstext='0';
run;
My output then looks like this:
How can I color certain cells and add pictures of a cockatiel, rabbit, and turtle? Something like this:
Can I just add to my proc tabulate to add the colors and the images? Also, how can I move the "# of pets" to the spot in the 2nd output?
data cutepets;
length pet $20;
input gender $ pet $ number_of_pets;
cards;
boy cockatiel 1
boy turtle 3
boy rabbit 4
girl cockatiel 2
girl turtle 3
girl rabbit 7
;
run;
proc format;
value $ image(default=80)
'cockatiel'='c:\temp\a.png'
'turtle'='c:\temp\b.png'
'rabbit'='c:\temp\c.png'
;
run;
title "Number of Cute Pets Owned by Families of 3rd Graders";
proc tabulate data=cutepets style=[just=center ];
class gender /style={background=blue color=white};
class pet /style={background=pink color=white};
classlev gender /style={background=purple color=white};
classlev pet /style={background=green color=white postimage=$image80. };
var number_of_pets;
table gender='Gender',
pet='Pet'* number_of_pets='' * sum=' ' /
box='# of Pets' misstext='0';
run;
data cutepets;
length pet $20;
input gender $ pet $ number_of_pets;
cards;
boy cockatiel 1
boy turtle 3
boy rabbit 4
girl cockatiel 2
girl turtle 3
girl rabbit 7
;
run;
proc format;
value $ image(default=80)
'cockatiel'='c:\temp\a.png'
'turtle'='c:\temp\b.png'
'rabbit'='c:\temp\c.png'
;
run;
title "Number of Cute Pets Owned by Families of 3rd Graders";
proc tabulate data=cutepets style=[just=center ];
class gender /style={background=blue color=white};
class pet /style={background=pink color=white};
classlev gender /style={background=purple color=white};
classlev pet /style={background=green color=white postimage=$image80. };
var number_of_pets;
table gender='Gender',
pet='Pet'* number_of_pets='' * sum=' ' /
box='# of Pets' misstext='0';
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.