SAS UniversityEdition
This is the log file when I run the Turnip Chart demo: Can SAS UniversityEdition runn this code and how?
Here is a graph with program. You could restructure your data by category (each of the "Kxx" columns for easier processing. Anyway, I kept your data structure, and just added some columns with the last 3 characters of each response variable as the category, such as "K01", "K02", etc, and used them with the corresponding response variable.
%let gpath='.';
%let dpi=150;
ods html close;
ods listing image_dpi=&dpi gpath=&gpath;
/*--Read datra from Excel--*/
proc import datafile="C:\qry_hip.xlsx"
dbms=xlsx out=Hip_Replacement replace;
run;
/*--Add some categories--*/
data hip;
set hip_replacement;
K01='K01'; K02='K02'; K03='K03'; K04='K04'; K05='K05';
run;
/*--Plot Graph--*/
ods graphics / reset width=5in height=3in imagename='Turnip_Hip';
proc sgplot data=hip nocycleattrs noautolegend;
scatter x=k01 y=HipReplacementper1K01 / jitter;
scatter x=k02 y=HipReplacementper1K02 / jitter;
scatter x=k03 y=HipReplacementper1K03 / jitter;
scatter x=k04 y=HipReplacementper1K04 / jitter;
scatter x=k05 y=HipReplacementper1K05 / jitter;
xaxis display=(noticks nolabel);
yaxis display=(nolabel);
run;
(Editor's note: Full example of a scalable Turnip graph is available on this blog post.)
GOPTIONS is related to settings for the traditional device based graphics found in SAS/GRAPH which is not part of University edition.
Look at the ODS GRAPHICS statement to set options such as IMAGEFM. But PNG will generally be the default for graphics so you may not need to worry.
As noted by "ballardW", SAS/GRAPH is not included with SAS University Edition. But Base Graphics procedures are included such as SGPLOT. Reviewing Robert's example, it looks like a "Jittered" scatter plot. Should be doable using SGPLOT.
%let gpath='.';
%let dpi=200;
data mydata;
format percent percentn9.2;
format cum_percent percentn9.2;
input mpg freq percent cum_percent;
percent=percent/100;
cum_percent=cum_percent/100;
Cat='A';
datalines;
11.57101 2 2.70 2.70
13.88521 8 10.81 13.51
16.19941 8 10.81 24.32
18.51361 17 22.97 47.30
20.82781 8 10.81 58.11
23.14201 12 16.22 74.32
25.45621 8 10.81 85.14
27.77042 3 4.05 89.19
30.08462 4 5.41 94.59
34.71302 3 4.05 98.65
41.65562 1 1.35 100.00
;
run;
/*--Expand the data--*/
data expand;
set mydata;
do i=1 to freq;
output;
end;
run;
/*--Draw Graph--*/
title;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
ods graphics / reset width=3in height=2in imagename='Turnip';
proc sgplot data=expand;
scatter x=cat y=mpg / jitter;
refline 20;
xaxis display=(noticks novalues nolabel);
run;
How do I adapt demo code to use my sas data set and variables
Can you suggest how I can produce turnip charts of variables in qry_hipReplacement1992to2013.xlsx
Greatly appreciative,
jemohr22
Which variable from this data do you want to plot? This is one of them.
The hipreplacement variable you chose is good. What does the sas code look like?
My professor asked me to produce a series of turnip graphs
Thank you
I need to produce a series of Turnip Charts for all variables in this data set. It appears that you were able to successfully produce a Turnip Chart for one of the variables. Could you share the code? I assume that with the code I will be able to simply change the variable name
In an ideal world I would be able to display a Turnip Chart Graphic for multiple variables in the same output. See attached pdf file
Here is a graph with program. You could restructure your data by category (each of the "Kxx" columns for easier processing. Anyway, I kept your data structure, and just added some columns with the last 3 characters of each response variable as the category, such as "K01", "K02", etc, and used them with the corresponding response variable.
%let gpath='.';
%let dpi=150;
ods html close;
ods listing image_dpi=&dpi gpath=&gpath;
/*--Read datra from Excel--*/
proc import datafile="C:\qry_hip.xlsx"
dbms=xlsx out=Hip_Replacement replace;
run;
/*--Add some categories--*/
data hip;
set hip_replacement;
K01='K01'; K02='K02'; K03='K03'; K04='K04'; K05='K05';
run;
/*--Plot Graph--*/
ods graphics / reset width=5in height=3in imagename='Turnip_Hip';
proc sgplot data=hip nocycleattrs noautolegend;
scatter x=k01 y=HipReplacementper1K01 / jitter;
scatter x=k02 y=HipReplacementper1K02 / jitter;
scatter x=k03 y=HipReplacementper1K03 / jitter;
scatter x=k04 y=HipReplacementper1K04 / jitter;
scatter x=k05 y=HipReplacementper1K05 / jitter;
xaxis display=(noticks nolabel);
yaxis display=(nolabel);
run;
(Editor's note: Full example of a scalable Turnip graph is available on this blog post.)
Here is the code I ran. The excel file was located at C:\qry_hip.xlsx
It appears that some of the code in the first demo code example is missing from the code you sent along with the Turnip Chart depicting multiple years.
Instead of importing the qry_hips.xlsx could I reference a SAS data set created by importing the qry_hips.xlsx to create a SAS dataset WORK.QRY_HIPS92TO13
I have tried running the code you sent, but I get multiple error messages including that the physical file qry_hips.xlsx can not be found or does not exist
Could you please forward a copy of all code used to produce the multi year Turnip Chart. I should be able to produce similar charts using the SAS University Edition by changing a few variable names
I am facing a publication deadline
Thanks again for your help
"qry_hips.xlsx" is the same as your original xlsx file. I used proc IMPORT to read the Excel data. I don't know if UA has PROC IMPORT? I attached the data set I imported in a zip file. You can try using that.
I appreciate the value of your time and would be grateful if you could guide me to the point of having a SAS program that produces a turnip chart for my HLTHDATA.HIPS9213 SAS dat set.
I imported qry_hips.xlsx into a SAS data set into a library, HLTHDATA.HIPS9213. The attached pdf file is the output of proc contents on HLTHDATA.HIPS9213. It lists the variable names I will need to use. I should be able to access this SAS data set using the data step:
data WORK.HIPREP;
set HLTHDATA.HIPS9213;
run;
What follows this data step? Where is the code that functions as the following sections of the original demo code?
Thank you so very much!
I was able to make it work.
Now I will tweak refinements to the display
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.