Hi
I have the below code, but instead of summer, i want to have the mean var of spi. Also, how can I give annotations ( like each color presenting which location)?
axis1 label=(h=0.17 in f=triplex "SPI and count by Year and location")
value=(h=0.135 in f=triplex) minor=none value=(h=0.07 in f=triplex a=-45)
color=black;
axis3 label=none;
proc gbarline data=totalc;
bar Year/ sumvar=SPI subgroup=loc width=2 discrete no frame space=1 axis=axis2 maxis=axis1;
plot /sumvar=count axis=axis3;
run;
quit;
This is very helpful and fixed the issue. Thanks a lot.
I tried that in different ways but I could not make clusters or plots by different variables. with this code i could get the graph and summery the data i want as below:
but now the problem is the precipitation is sum and I want mean. I was able to add annotations.
@Reeza is correct. Run the example below and see if this is the desired output. Your data should fit into this pattern. You can also add a discrete attribute map to this example if you want to control the assignment of particular colors to group values.
Hope this helps!
Dan
proc summary data=sashelp.cars nway;
class origin model;
var msrp;
output out=barcars mean=mean_msrp;
run;
proc summary data=sashelp.cars nway;
class origin;
var horsepower;
output out=linecars mean=mean_power;
run;
data cars;
merge barcars linecars;
by origin;
run;
proc sgplot data=cars;
y2axis min=0 offsetmin=0;
yaxis offsetmin=0;
vbarparm category=origin response=mean_msrp /
group=model groupdisplay=cluster;
series x=origin y=mean_power / y2axis markers;
run;
this is really helpful, but there is a problem. i have my code below, for some reason the calculation of my count_sum is not correct in fact the count sum should be the total of counts per year per location but what this code is giving me is different number ( it is giving the sum of counts per year it is not stratified by loc).
proc summary data=totalc nway;
class loc year;
var spi;
output out=spimean mean=mean_spi;
run;
proc summary data=totalc nway;
class year;
var count;
output out=countsum sum=count_sum;
run;
proc sgplot data=totalnew;
y2axis min=0 offsetmin=0;
yaxis offsetmin=0;
vbarparm category=year response=mean_spi /
group=loc groupdisplay=cluster;
series x=year y=count_sum / y2axis markers;
run;
Your CLASS statement needs to have "year loc", not "loc year". That's what is causing the miscalculation.
This is very helpful and fixed the issue. Thanks a lot.
after fixing the issue,
I wonder if there is a way I can give color or shape to my circle dots in the below graph. now my bar has a color which is indicating the measure of spi by loc but my circle dots are all the same so it is not expressing count by loc. Is there a way to specify that too?
If you want the plot to be group-sensitive, get rid of the proc summary and data step calls and simply run the following code:
proc sgplot data=totalc;
y2axis min=0 offsetmin=0;
yaxis offsetmin=0;
vbar year / response=spi stat=mean group=loc groupdisplay=cluster;
vline year / response=count stat=sum group=loc y2axis markers;
run;
It is fixed now. Thank you
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.