If my data creates hundreds of gplots after using a BY statement.. How can I limit the number.. say I want to only view the first 20 or 30.. thanks
proc gplot data=whatever (obs=###)
Pick a number that represents enough observations for 20 or 30 plots, and ignore the last plot since it may be incomplete.
If you want a more scientific version, you could run through a DATA step to create a subset of your data:
data subset;
set whatever;
by my_by_var;
if last.my_by_var then n_plots + 1;
output;
if n_plots=25 then stop;
run;
Then run PROC GPLOT on the subset.
Thanks Astounding..
Or, since your BY variable is in some kind of order, pick the one that's about 20th and use a WHERE statement:
where char_byvar le 'DEPT20';
or
where num_byvar le 54;
directly in your GPLOT:
proc gplot data=whatever;
...where statement....;
*plot statements;
run;
quit;
cynthia
Thanks Cynthia, would you know how I can I limit the number of inputs shown on the x-axis (eg. Date..) I have way too many showing ?
I assume that you mean you have x values out of a desired range.
you can add an option to your plot statement (s) like: / haxis= value1 to value2 by increment
ro define an AXIS statement if you need more control and reference it:
/haxis=axis1
This approach of restricting range usually generates a warning message if I remember correctly.
If your x values are dates or times some other bits come in how to specify them.
Thanks Ballardw, but I mean more like instead of showing 2000.01 ... 2000.02 ..... 2000.03 and so on, which crams it up.. I want to show only say years or quarters or something like 2000.01... 2000.06 that sort of thing.
hi ... have you tried just using a format , for example the dates in SASHELP.AIR have year and month but you can plot by year on the x-axis ...
goptions reset=all;
proc gplot data=sashelp.air;
plot air*date;
format date year.;
run;
quit;
Actually my example does limit the number of displayed values as well as the range. The BY incremental value controls how many tick marks are displayed.
for examle haxis = 0 to 100 by 50 would have 3 major tick marks at 0, 50 and 100.
I looks like you may have x as a date value and a format of YYMMp8. You could try a YYQ to show year quarter values or YEAR. as MikeZdeb suggests.
hi ... if you know something about the values of the BY-variable, you can use a WHERE statement
for example ...
data air;
set sashelp.air;
year = year(date);
run;
goptions reset=all;
proc gplot data=air;
plot air*date;
by year;
where year between 1950 and 1952;
run;
quit;
if you want to limit the output by the number of plots, you could try something like this ...
ods listing close;
proc sql number;
ods output sql_results=temp;
select distinct year from air;
ods output close;
select year into :years separated by ',' from temp where row le 5;
quit;
ods listing;
* generates 5 plots;
proc gplot data=air;
plot air*date;
by year;
where year in (&years);
run;
quit;
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.