- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
i am having issue with proc sgplot xaxis values. here is my code
ods pdf file="R:\\14.1.4.pdf";
proc sgplot data=count dAttrMap=attrmap ;
by cohort subject;
/* The ATTRID option references the name of the attribute map */
vbar day / group=organism grouporder=ascending attrid=organism barwidth=0.3 ;
xaxis label="Study Day" values=(0 to 8 by 1);
yaxis values=(0 to 8 by 1);
format day dy.;
title1 "VE303 Detection panel-Stacked bar charts";
run;
ods pdf close;
when i got the output it is not taking from 0 to 8 by 1.
please help to get the xaxis values as mentioned . look at the output picture on top.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What does the log show?
@Anushavalli wrote:
Hi everyone,
i am having issue with proc sgplot xaxis values. here is my code
ods pdf file="R:\\14.1.4.pdf";
proc sgplot data=count dAttrMap=attrmap ;
by cohort subject;
/* The ATTRID option references the name of the attribute map */
vbar day / group=organism grouporder=ascending attrid=organism barwidth=0.3 ;
xaxis label="Study Day" values=(0 to 8 by 1);
yaxis values=(0 to 8 by 1);
format day dy.;
title1 "VE303 Detection panel-Stacked bar charts";run;
ods pdf close;when i got the output it is not taking from 0 to 8 by 1.
please help to get the xaxis values as mentioned .
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You say
when i got the output it is not taking from 0 to 8 by 1
So what is it showing?
It would be a good idea to insert a picture of your result so we can see what you are getting.
Or Provide example data in the form of data step code so we can run the program with that data to see.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
updated with output.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
please post your log?
As a quick alternative, you could simply use a WHERE Statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
can you please let me know exact place to apply WHERE statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The VBAR x-axis is considered discrete by default. Since you did not provide data, it is not clear if the "day" variable is numeric or character. If "Day" is numeric, providing a VALUES option with linear data should still work. These would be in data range, not indexes. If "Day" is numeric, you can also make the x-axis TYPE=LINEAR. Else, you can provide the values you want as quoted character values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Day variable is Numeric even though values statement is not working out .if i give TYPE=LINEAR then pdf is not generating the vbars.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I was running into a similar issue recently, in which I need to hide some of the x axis values in my graph.
First, I used values=() option in the xaxis statement, but it did not work.
Finally, in the documentation, I find fitpolicy=thin option in the xaxis statement and get the result I want.
Back to your issue, I think you did not have any obs with values other than 0 8 10 of variable day in your dataset.
Such as:
data tmp;
input day organism;
cards;
0 1
8 1
10 1
;
run;
proc sgplot data=tmp noautolegend;
vbar day/response=organism nooutline stat=freq barwidth=0.3 transparency=0;
xaxis label="Study Day";
yaxis values=(0 to 8 by 1);
title1 "VE303 Detection panel-Stacked bar charts";
run;
Which generates plot like this:
Thus you might create additional obs with values 1 to 7, and 9 (those you want to display on the x axis) of variable day with missing values of organism.
data tmp;
input day organism;
cards;
0 1
8 1
10 1
1 .
2 .
3 .
4 .
5 .
6 .
7 .
9 .
;
run;
Then, rerun the same code, and you will get the result you want as follows 🙂