Hi,
I am a month-old user of SAS VA 7.3 and have no experience at all for with writing the code.
Here is what I am trying to achieve and hope some of you can help.
I have loaded my source from an excel file with the following data:
Project | Software 1 | Number of copies | Software 2 | Number of copies | Software 3 | Number of copies |
A | Excel | 2 | Word | 1 | Powerpoint | 1 |
B | Word | 1 | Photoshop | 2 | Visio | 1 |
C | Powerpoint | 3 | Excel | 1 |
I would like to be able to show the above data using a pie chart to show the number of copies used in the projects.
As the software may differ for every project, you may have new software appearing in any of software columns.
Hope the problem is clear.
Thank you very much for your help.
Firstly, it is better to transpose the horizontal table to vertical. Then you can use PROC GCHART to create pie chart. There are two kinds pie chart: Individual or stacked. I enclosed codes for both chart. You can do further appearance adjustments. It is always good to read SAS documents.https://documentation.sas.com/?docsetId=graphref&docsetTarget=p13h0w5vhbfvern1a23b0f3lvfyh.htm&docse...#
data have; infile datalines missover; input project $ software1 : $20. number1 software2 : $20. number2 software3 : $20. number3; datalines; A Excel 2 Word 1 Powerpoint 1 B Word 1 Photoshop 2 Visio 1 C Powerpoint 3 Excel 1 ; run; ***** Transpose from horizontal to vertical ****; data have2; length software $20; set have; array x software1-software3; array y number1-number3; do i=1 to dim(x); software = strip(x(i)); number = y(i); output; end; keep project software number; run; ***** individual Pie per Project ****; proc gchart data = have2; pie software / sumvar=number group=project type=sum nolegend slice=outside percent=none value=outside ; run; ***** stacked Pie per Project ****; PROC GCHART DATA = have2; pie software / sumvar=number subgroup=project type=sum slice=inside percent=none value=inside coutline=black ; run;
Thank you @MINX.
I am sorry I am really new. Where can I add those code above in SAS VA 7.3?
Will the code below works for more than just 3 rows of data?
data have; infile datalines missover; input project $ software1 : $20. number1 software2 : $20. number2 software3 : $20. number3; datalines; A Excel 2 Word 1 Powerpoint 1 B Word 1 Photoshop 2 Visio 1 C Powerpoint 3 Excel 1 ; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.