BookmarkSubscribeRSS Feed
viollete
Calcite | Level 5

Hi all!

 

I want to make a graph: in the x axis i want to put month and lower year, and in Y axis rate.

 

How can I do it?

 

Thanks!

8 REPLIES 8
Reeza
Super User

Do you mean multiple X axis or multiple labels on the X axis?

 

It helps if you show a picture and sample data that mimics your data.

viollete
Calcite | Level 5
I have one variable that indicates month(1,2,3,4,5,..) and i have one variable that indicate year (2008, 2009,...). I want to see months and below each January (that would be 1) to see year
DanH_sas
SAS Super FREQ

I think the easiest way to handle this case is to combine the two variables into a SAS date variable and use that variable in SGPLOT. Here is a simple example:

 

data datedata;
format newdate monyy.;
do year=2000 to 2002;
  do month=1 to 12;
      newdate = mdy(month,01,year);
      y=ranuni(123);
      output;
  end;
end;
run;

proc sgplot data=datedata;
scatter x=newdate y=y;
run;

viollete
Calcite | Level 5
Thanks, but it doesn't do what i want, it shows just years, but I want to see months and years
DanH_sas
SAS Super FREQ

Your data must contain at least several years worth the information. The system determined that the best format for your time axis was years. You can force it to months by adding this statement to your SGPLOT code;

 

xaxis interval=month;

 

Hope this helps!

Dan

viollete
Calcite | Level 5
Sorry, it still doesnt work as I would like..it put year below month but I get this: 2008 below JAN, 2009 below APR, 2010 below FEB.....and I would love it to be like this:
2008 below JAN, 2009 below JAN, 2010 below JAN
DanH_sas
SAS Super FREQ

Hmmm..  I'm not sure how you would get behavior. When I run the code I gave you from 2000 to 2005, I get the attached picture. Can you show us your SGPLOT code (without the data)?

 

Thanks!

Dan


dates1.png
DanH_sas
SAS Super FREQ

Try this and see if this is what you want:

 

proc sgplot data=sashelp.air;
where date between '01jan1955'd and '01jan1957'd;
series x=date y=air;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1883 views
  • 0 likes
  • 3 in conversation