BookmarkSubscribeRSS Feed
Anushavalli
Calcite | Level 5

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

 

 

 

8 REPLIES 8
Reeza
Super User

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

 

 


 

ballardw
Super User

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.

Anushavalli
Calcite | Level 5

updated with output.

 

Thank you

PeterClemmensen
Tourmaline | Level 20

please post your log?

 

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

Anushavalli
Calcite | Level 5
log does not have any warnings or errors..
can you please let me know exact place to apply WHERE statement.
Jay54
Meteorite | Level 14

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.

Anushavalli
Calcite | Level 5

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

GFW
Obsidian | Level 7 GFW
Obsidian | Level 7

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:

 

 

SGPlot45.png

 

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 🙂

SGPlot43.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 2296 views
  • 0 likes
  • 6 in conversation