Hello,
i created graphs, by gplot. i want to change scaling for every graph(i create graph for every security - see by) , how can i drp it?
i.e for every security i have different scale, i want to use scaling inside dataset and to use in the order statement. can i?
for example :
axis1 label=none minor=none offset=(0,0);
axis2 label=none minor=none offset=(0,0) order=(100 to 150 by 5);
proc gplot data=test;
plot price*time=1 / overlay vaxis=axis1 haxis=axes2 noframe;
by security;
run;
thank you
Alexey
And You are not satisfied with gplots autoscaling in case you omit either vaxis haxis or both
no, unfortunately not, i want to see behavior of price in the specific interval
The simple answer is to move your code to use Graph Template Language. Then is really simple:
proc template;
dynamic _low _high _by;
begingraph /;
layout overlay / xaxisopts=(viewmin=_low viewmax=_high);
...
run;
proc sgrender ...;
dynamic _low=100 _high=150 _by=5;
run;
Otherwise you can do it by generating the code (however do consider moving to the newer technology):
data ranges;
low=100; high=150; b=5; output;
low=200; high=300; b=10; output;
run;
data _null_;
set ranges;
call execute(cats('axis2 order=(',put(low,best.),' to ',put(high,best.),' by ',put(b,best.),';'));
run;
i didn't know Graph Template Language, but the second option is interesting, can you explain me in more details please.
Graph template language is the latest graphing technology. Been around since 9.x, the newer graphing plots - sgplot for instance, create GTL behined the scenes. It is far more powerful, easier to understand than the old graphing system. Have a look at Sanjay's excellent blog where you will find examples of pretty much anything you can think of: http://blogs.sas.com/content/graphicallyspeaking/
As for my second options, what I am doing is generating the code. The call execute function takes a string, and sends that string to the compiler as if it was normal code. Thus any string of code you can create can be executed. Say for instance, I want to print two datasets, I could do this as:
data _null_;
do i=dataset1,dataset2;
call execute(cats('proc print data=',i,'; run;'));
end;
run;
This will create two strings and send them to the compiler as:
proc print data=dataset1; run;
proc print data=dataset2; run;
So from the axis example, the dataset ranges has two rows, in the first row of data an axis statement is generated with the data from that row and sent to the compiler, then the next row. In that instance only the second row really takes any effect, but if you put the graph statement in the call execute, then the gpplot would also be called, so you get two sets of code, one for each of the ranges.
And why the OVERLAY option?
I assume that's to me? It doesn't matter, I just pulled that code from a program.
Actually the question is for the OP.
Sort of wondering when that appears if maybe what was actually wanted was a
plot price*time=security
as attempting to overlay multiple graphs with the same marker/line seems odd. IF that was the intent.
i will explain what i want to do.
i have a list of securities price and time of transaction. i want to create graph per every security and date, axe x= time axe y =price
i have a lot of securities, for exeery security i want to define the scale of axe y. how can i do it.
i know that using order=() i need put there values, and it is not rellevant in this case.
what can i do?
thank you
because i have another one graph on the same graph.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.