Questions tagged [sgplot]
49 questions
4
votes
2 answers
Different label for each bar in a bar chart using Proc sgplot
I'm trying to add the number of each group into the labels of groups on xaxis using Proc sgplot in SAS. Here is the data and the graph I'd like to have. I want to have sample of each bar on xaxis (hand writen parts). Your help is very much…

kiabar
- 63
- 6
4
votes
3 answers
How to plot a simple lineplot in SAS
My data are structured as follows (these are just sample data as the original data are secret)
id | crime | location | crimedate
------------------------------
1 | Theft | public | 2019-01-04
1 | Theft | public | 2019-02-06
1 | Theft …

D. Studer
- 1,711
- 1
- 16
- 35
2
votes
2 answers
Overlaying time series for individuals and mean values in a single graph using SAS SGPLOT
I am comparing the evolution of plasma concentrations over time for different treatments of patients.
We applied each treatment to different subjects and for each treatment we want a graph with the evolution for each subject in black, as well as…

Shef
- 21
- 3
2
votes
2 answers
SAS problem with curvelabelpos and xaxis in PROC SGPLOT
I am currently trying to use PROC SGPLOT in SAS to create a series plot with five lines (8th grade, 10th grade, 12th grade, College Students, and Young Adults). The yaxis is a percentage of prevalence in drug use ranging from 0-100. The xaxis is the…

Scott F
- 37
- 7
2
votes
1 answer
By group controlling line colors/where clause
I want to plot Y by X plot where I group by year, but color code year based on different variable (dry). So each year shows as separate line but dry=1 years plot one color and dry=0 years plot different color. I actually figured one option (yeah!)…

user9166085
- 33
- 7
2
votes
2 answers
How to add a custom fitted line to SAS SGplot Scatter
I have a simple SAS data set I am plotting as a scatter plot, my two questions are:
I am trying to adjust the y-axis without excluding the (0.02,51) data point but I need the y-axis to only show 60 to 160 by 20. When I define this it excludes that…

Bfran
- 21
- 2
1
vote
2 answers
SAS SGPLOT yaxis discreteorder=formatted: Force numerical sorting instead of lexigraphical
I'm creating a heatmap with discrete X and discrete Y axis. The discrete Y axis is numerical (BEST12.) but yaxis discreteorder=formatted and discreteorder=unformatted are both sorting the variable lexigraphicly.
Expected: 1 2 3 4 5 ... 10 11 12 ...…

AlexStudentCSU
- 21
- 2
1
vote
2 answers
SAS: Generate separate plots for a list of variables in a single SGPLOT statement (such as can be done with PROC UNIVARIATE or PROC CHART)
A dataset has 10 variables ('a' through 'f'), half quantitative and half categorical, and you want to generate a separate visual representation of each of these variables (histograms for the quantitative and bars for the categorical) with the…

AlexStudentCSU
- 21
- 2
1
vote
2 answers
Creating a histogram and afterwards adding points to it using SGPLOT
I have some data for six different columns that I want to create a histogram for each column. This is pretty straight forward where I can use SGPLOT, for example
PROC SGPLOT DATA=test;
HISTOGRAM leverage;
RUN;
However, now I want to calculate…

Mathias Nissen
- 27
- 3
1
vote
1 answer
Generate a plot from random numerical vector in SAS
I'm quite new to SAS,
I have learned about SGplot, Datalines, IML and randgen.
I'd like to simply generate a random data for a simple scatter plot.
/* declaring manually a numeric list */
data my_data;
input x y @@;
datalines;
…

bcg
- 17
- 4
1
vote
1 answer
Merging class panels with SGPANEL for SAS
Suppose I have a data set with class variable with 4 levels: A, B, C and D. If I want to creater four series plots in SAS Studio I can run the following code using proc sgpanel.
proc sgpanel data = name;
panelby class;
series X = var1 Y = var2 /…

Jacobiman
- 155
- 5
1
vote
1 answer
How to create connected sas line plot with breaks for missing data
I have diary data with a day a row, but some days are missing. I want the missing days to be shown as broken in the lines. Currently if I use sgplot's step statement, it is shown as connected. Any idea? Here is a simplified sample data
data diary;
…

Karen L
- 31
- 3
1
vote
2 answers
How to insert the #byval value in the png filename when using sgplot with a by statement in SAS
I'm making several png image using sgplot and the by statement like this:
ods html path="&graphPath" body="index.html"
image_dpi=300 style=sciensano1 device=png;
ods graphics on / reset noborder imagename="boom"
height=10cm width=16cm…

stallingOne
- 3,633
- 3
- 41
- 63
1
vote
3 answers
How Do I Write A Do-Loop That Creates A Graph For Each Unique Person?
I am trying to run through a large data set and create a simple scatter plot for each person. I would like to run this in SAS using a do loop and proc sgplot.
My dataset is the following:
Person Date QTY Brand
Jim | August…
user10745594
1
vote
1 answer
SAS: change the colour and thickness of the reference label in proc gplot
I am trying to plot the different levels of salary in a needle plot and I'd like a reference line. The following code provides this reference line but the line is the same colour as the needles and is too thin. Is there a way to change…

78282219
- 85
- 1
- 8