BookmarkSubscribeRSS Feed
AlexeyS
Pyrite | Level 9

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

10 REPLIES 10
jkanters
Fluorite | Level 6

And You are not satisfied with gplots autoscaling in case you omit either vaxis haxis or both

AlexeyS
Pyrite | Level 9

no, unfortunately not, i want to see behavior of price in the specific interval

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

AlexeyS
Pyrite | Level 9

i didn't know Graph Template Language, but the second option is interesting, can you explain me in more details please.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ballardw
Super User

And why the OVERLAY option?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

I assume that's to me?  It doesn't matter, I just pulled that code from a program.

ballardw
Super User

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.

AlexeyS
Pyrite | Level 9

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

AlexeyS
Pyrite | Level 9

because i have another one graph on the same graph.

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
  • 10 replies
  • 1470 views
  • 0 likes
  • 4 in conversation