I have a dataset that has a Month variable, and calculated the medians of the 5 other variables in my dataset.
proc means data = final4 noprint;
by Month;
var High Low Precip Snow SnowDepth;
output out = final5(drop=_type_ _freq_)
median = /autoname;
run;
I output it to the temp dataset final5. Now I need to plot a barchart (histogram) of one of my variables by month, so it would look like Month on the x axis and, let's say Snow, on the yaxis, and It would plot the medians of Snow for each month. I have tried proc gplot and proc splot, but the stat functions they have do not include the median, and I can't find another way to plot a barchart that would include both variables.
I appreciate any help anyone can provide.
Thanks!
Adam
Look at using VBARPARM instead of VBAR.
@BoboTheFool wrote:
I figured it out, kinda backed into a solution. Since I saved the dataset as medians of each month for each variable, when I plotted vbar Month / response = Precip_Median; it plotted what I needed, sort of by default.
Show the code you tried, specifically the SGPlot code.
You have summary data so you shouldn’t be requesting any statistics, just do a bar plot instead.
A histogram shows a distribution, your graph would not be called a histogram.
PS. Please mark your previous questions as answered.
@BoboTheFool wrote:
I have a dataset that has a Month variable, and calculated the medians of the 5 other variables in my dataset.
proc means data = final4 noprint; by Month; var High Low Precip Snow SnowDepth; output out = final5(drop=_type_ _freq_) median = /autoname; run;
I output it to the temp dataset final5. Now I need to plot a barchart (histogram) of one of my variables by month, so it would look like Month on the x axis and, let's say Snow, on the yaxis, and It would plot the medians of Snow for each month. I have tried proc gplot and proc splot, but the stat functions they have do not include the median, and I can't find another way to plot a barchart that would include both variables.
I appreciate any help anyone can provide.
Thanks!
Adam
I figured it out, kinda backed into a solution. Since I saved the dataset as medians of each month for each variable, when I plotted vbar Month / response = Precip_Median; it plotted what I needed, sort of by default.
Look at using VBARPARM instead of VBAR.
@BoboTheFool wrote:
I figured it out, kinda backed into a solution. Since I saved the dataset as medians of each month for each variable, when I plotted vbar Month / response = Precip_Median; it plotted what I needed, sort of by default.
Thanks @Reeza . A quick question - When I run a proc means and get the statistics (mean, median, etc,), is there a way I can rename the mean descriptor? And example. Proc means labels Q1 as the lesser quantile or something like that. Is there a way I can change that label to just Q1?
so here is my code @Reeza
proc means data = final4 Q1 median Q3;
var High Low Precip Snow SnowDepth;
label High = "High";
label Low = "Low";
label Precip = "Precip";
label Snow = "Snow";
label SnowDepth = "SnowDepth";
title "Quantiles of the Weather Variables of 2018";
run;
I would like to change the lower and upper quantile names to Q1 and Q3 for the below output
Quantiles of the Weather Variables of 2018
The MEANS Procedure
Variable Label Lower Quartile Median Upper Quartile
32.0000000 16.0000000 0 0 0 | 51.1000000 30.9000000 0 0 0 | 75.9000000 55.9000000 0.0200000 0 0 |
@BoboTheFool wrote:
Quantiles of the Weather Variables of 2018
The MEANS Procedure
Variable Label Lower Quartile Median Upper Quartile
HighLowPrecipSnowSnowDepthHighLowPrecipSnowSnowDepth
32.000000016.0000000000 51.100000030.9000000000 75.900000055.90000000.020000000
Send output to the LISTING destination and then copy from the output window into a code box. The above is essentially unreadable.
The question remains, are you sending the results to a data set or not? At the top of the topic you were but now it appears that you are not.
You can add a rename dataset option on the output to change the NAMES of variables.
If you want the proc means output directly to be "prettier" you might try one of the report procedures such as Proc Tabulate or Report that will allow setting labels and formats "nicer" than proc means.
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.