- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
/* Creating the table */
data piechart;
input slice $ Vente Age;
datalines;
A 35 12
B 10 2
C 22 22
D 40 67
;
run;
/*Creating the pie chart */
proc sgplot data=piechart;
pie slice=Age ;
run;
Hello,
I want to make a pie chart (in percentage).
Each sector takes the value of the Vente so that their sum can make 100%.
I tried this code but it doesn't work. Here is a picture of what I want.
Can someone help me please.
Gick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you check the documentation for SGPLOT, such as here: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/p1x0rnjgnvfw20n1scpxlolgjeok.htm you will find that there is NO "pie" plot.
Proc SGPie makes pie-charts: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n11xqf2g2rxnmbn1pgk4rbl5vz80.htm
I think you may want
proc sgpie data=piechart; pie Age / response= age datalabelloc=inside; run;
Doesn't work is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have this error message in the log. "ERROR: Procedure SGPIE not found."
Why this problem?
Can someone help me please.
Gick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SGPIE is only available in SAS 9.4M6 or later. Run this to confirm your SAS version and maintenance level:
proc product_status;
run;
For earlier versions PROC GCHART with the PIE statement should work if you have SAS/GRAPH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is the log:
For Logiciel Base SAS ...
Custom version information: 9.4_M3
Image version information: 9.04.01M3P062415
For SAS/STAT ...
Custom version information: 14.1
For SAS/GRAPH ...
Custom version information: 9.4_M3
For SAS/ETS ...
Custom version information: 14.1
For SAS/AF ...
Custom version information: 9.4_M3
For SAS/IML ...
Custom version information: 14.1
For SAS/CONNECT ...
Custom version information: 9.4_M3
For High Performance Suite ...
Custom version information: 2.2_M4
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M3
For SAS/ACCESS Interface to ODBC ...
Custom version information: 9.4_M3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
With a single slice variable, I have the pie chart fine. This graph is represented in relation to the distribution of slice whereas I want it to take into account the values of the age.
Does anyone have any idea how we can get back to my concern (original question)
Best regards,
Gick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
https://blogs.sas.com/content/graphicallyspeaking/2012/03/26/let-them-eat-pie/
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here we deviate a little from what I am looking for.
The idea is to take into account information from the Age variable and assign it to each slice.
This code just gives me the pie chart of the variable slice.
THANKS.
I always try to meet my initial objective.
Gick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
set piechart;
do i=1 to age;
output;
end;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No, it doesn't. With the proposed code, the loop i goes from 1 to age. It is heavy.
You should know that the variable age has modalities of 20, 30, 10, etc.
If I had SAS version 9.4M6, the proc sgpie should resume to my concern I think.
I'm always open to suggestions.
Best regards,
Gick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But on SAS, I'm having trouble doing that.
Can someone help me please
Best regards,
Gick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Gick wrote:
With Excel, I just have to calculate the sales percentage and then I make a pie chart using the slice variable as legend.
But on SAS, I'm having trouble doing that.
Can someone help me please
Best regards,
Gick
I feel your pain. But from the other side. I learned how to code and make charts in SAS years before Excel was written. then moved to a job that used Excel for everything. I got stuck making reports and was constantly going through the same steps manual of highlighting cells and defining series and options. Which from my SAS experience I should have been able to develop the code once and then use BY processing to make many similar charts.
You have not mentioned what environment you are running SAS with. It might be that you have the older SAS/Graph available. Run this code which will show all of the SAS modules you have licensed.
Proc setinit; run;
Then look in the Log. You should see something similar to the following: If your result includes SAS/Graph then you can use Proc GCHART with a Pie option.
Site number: 11111111. Expiration: 30JAN2024. Grace Period: 45 days (ending 15MAR2024). Warning Period: 45 days (ending 29APR2024). System birthday: 18MAY2017. Operating System: WX64_WKS. Product expiration dates: ---Base SAS Software 30JAN2024 ---SAS/STAT 30JAN2024 ---SAS/GRAPH 30JAN2024 ---SAS/Secure 168-bit 30JAN2024 ---SAS/Secure Windows 30JAN2024 ---SAS Enterprise Guide 30JAN2024 ---SAS/ACCESS Interface to PC Files 30MAY2062 ---SAS/ACCESS Interface to ODBC 30MAY2062 ---SAS Workspace Server for Local Access 30JAN2024 ---High Performance Suite 30JAN2024
The way the options are arranged for SAS/Graph, which was designed for pen-based plotters originally, means you will get to learn very different options for setting appearance than the Sgplot and newer procedures.
You will have to check the syntax for Proc Gchart. Check the examples in the online help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Follow the link I provided in my first post to PROC GCHART and the PIE statement.