proc format; value Activity 6='Creator' 5='Critic' 4='Collector' 3='Joiner' 2='Spectator' 1='Not Active'; run; data SocialMedia; input Age $1-5 @@; /* read first percentage ("Not Active" group) */ UseSocial = 0; Level = 1; input RawPct @@; output; /* read remaining percentages */ UseSocial = 1; do Level = 2 to 6; input RawPct @; output; end; format Level Activity.; datalines; 12-17 34 49 51 11 24 34 18-21 17 59 70 16 37 37 22-26 21 54 57 18 34 30 27-40 42 41 29 16 25 19 41-50 54 31 15 15 18 12 51-61 61 26 8 16 15 7 62+ 70 19 6 11 11 5 ; run; /* Alternative graph: Line plot that shows how participation in each activity varies by age. */ title1 "Online Activities: Who Participates?"; proc sgpanel data=SocialMedia; panelby Level/ onepanel novarname layout=ROWLATTICE uniscale=all start=BOTTOMLEFT; series x=Age y=RawPct; rowaxis min=0 Label="Percentage"; run; /* Alternative graph: Bar chart that shows the percentage of an age group that participates in each activity. */ proc sgpanel data=SocialMedia; panelby Age/ onepanel novarname layout=ROWLATTICE uniscale=all start=BOTTOMLEFT; vbar Level / freq=RawPct; rowaxis min=0 Label="Percentage"; run; /* Bar chart that shows the percentage of each age group that participates in online social media. */ data Active; set SocialMedia(where=(UseSocial=0)); Pct = 100-RawPct; run; title1 "Social Media Use By Age"; proc sgplot data=Active; vbar Age / freq=Pct; yaxis Label="Percentage"; run; /* Transform the data to show the percentage of PARTICIPANTS in each age group that take part in each activity. */ data Activities; set SocialMedia; retain PctActive; if (UseSocial=0) then PctActive = 100-RawPct; SocialPct = 100*RawPct / PctActive; if UseSocial; run; title1 "Participation in Social Media"; title2 "Of Those Who Participate, What Do They Do?"; proc sgpanel data=Activities; panelby Level/ onepanel layout=ROWLATTICE uniscale=all novarname start=BOTTOMLEFT; series x=Age y=SocialPct; rowaxis min=0 Label="Percentage of Group Using Social Media"; run; proc sgplot data=Activities; series x=Age y=SocialPct / group=Level curvelabel curvelabelpos=start; yaxis min=0 Label="Percentage"; run;