BookmarkSubscribeRSS Feed
stanh
Calcite | Level 5

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:

ProjectSoftware 1Number of copiesSoftware 2Number of copiesSoftware 3Number of copies
AExcel2Word1Powerpoint1
BWord1Photoshop2Visio1
CPowerpoint3Excel1  

 

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.

2 REPLIES 2
MINX
Obsidian | Level 7

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;



stanh
Calcite | Level 5

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 562 views
  • 0 likes
  • 2 in conversation