BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I want to do  plot of 2 vars.

The axis var is numeric with format YYMM.

What is the way to see in x-axis the values:  2201 till 2302

 


data have;
input YYMM Y :percent8.2;
format y percent8.2;
cards;
2201 0.18%
2202 0.19%
2203 0.22%
2204 0.04%
2205 0.23%
2206 0.27%
2207 0.26%
2208 0.04%
2209 0.06%
2210 0.09%
2211 0.03%
2212 0.04%
2301 0.03%
2302 5.3%
;
Run;
data have2;
set have;
sasdate = input(put(YYMM,4.),yymmn4.);
format  sasdate yymmn4.;
Run;
proc gplot data=have2;
plot y*YYMM/ 
                        vaxis=0 to 0.1 by 0.01
;
run;
4 REPLIES 4
Ronein
Onyx | Level 15

Please look at x-axis. I cannot see the x values well

quickbluefish
Barite | Level 11

Well, you have a couple problems - the main one is that you're not using you're newly created variable, SASDATE, in the GPLOT step - instead, you're using the original, unformatted version, YYMM.  You also might consider using SGPLOT rather than GPLOT to get more modern-looking graphics.  Also, since your data are longitudinal, it will probably be easier to visualize as a line (SERIES) rather than as a scatter plot.  Here's an extremely simple version:

proc sgplot data=have2 noautolegend;
series x=sasdate y=Y;
scatter x=sasdate y=Y / markerattrs=(size=5 color=black symbol=circlefilled);
run;
Ronein
Onyx | Level 15
Can you please show me how to use it with my sas date var?
In x axis I want to see all my date values.
GraphGuy
Meteorite | Level 14
data have;
length yymm $4;
input YYMM Y :percent8.2;
format y percent8.2;
datalines;
2201 0.18%
2202 0.19%
2203 0.22%
2204 0.04%
2205 0.23%
2206 0.27%
2207 0.26%
2208 0.04%
2209 0.06%
2210 0.09%
2211 0.03%
2212 0.04%
2301 0.03%
2302 5.3%
;

data want; set have;
length date_string $8;
date_string='20'||trim(left(yymm))||'15';
format  sasdate yymmn4.;
sasdate = input(date_string,yymmdd8.);

proc print data=want; 
format sasdate date9.;

axis1 label=none minor=none offset=(0,0) order=(0 to .1 by .01);
axis2 label=('YYMM') offset=(2pct,2pct)
 order=('15jan2022'd to '15feb2023'd by month);

symbol1 value=circle height=2pct color=blue;

title1 h=5pct "Values, by Month";

proc gplot data=want;
format y percentn7.0;
plot y*sasdate/
 autovref lvref=33 cvref=gray33
 vaxis=axis1
 haxis=axis2
;

yymm.png

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1005 views
  • 3 likes
  • 3 in conversation