Data visualization with SAS programming

Sgplot: vbar xaxis values

Reply
New Contributor
Posts: 4

Sgplot: vbar xaxis values

[ Edited ]

Capture.PNG

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

 

 

 

Super User
Posts: 22,874

Re: Sgplot: vbar xaxis values

Posted in reply to Anushavalli

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

 

 


 

Super User
Posts: 13,084

Re: Sgplot: vbar xaxis values

Posted in reply to Anushavalli

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.

New Contributor
Posts: 4

Re: Sgplot: vbar xaxis values

updated with output.

 

Thank you

PROC Star
Posts: 1,190

Re: Sgplot: vbar xaxis values

Posted in reply to Anushavalli

please post your log?

 

As a quick alternative, you could simply use a WHERE Statement.

New Contributor
Posts: 4

Re: Sgplot: vbar xaxis values

log does not have any warnings or errors..
can you please let me know exact place to apply WHERE statement.
SAS Super FREQ
Posts: 1,265

Re: Sgplot: vbar xaxis values

[ Edited ]
Posted in reply to Anushavalli

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.

New Contributor
Posts: 4

Re: Sgplot: vbar xaxis values

Posted in reply to Sanjay_SAS

Day variable is Numeric even though values statement is not working out .if i give TYPE=LINEAR then pdf is not generating the vbars.

Ask a Question
Discussion stats
  • 7 replies
  • 132 views
  • 0 likes
  • 5 in conversation