BookmarkSubscribeRSS Feed
lloydc
Calcite | Level 5

I have a few things I'm trying to do and my experience with macros and plots is pretty slim.

I have a varying number of datasets I'm bringing in. For example let's say there are six (6) data sets, each with the same fields. Each represents results of a different test with some difference in the make-up of the test (ex: micro-code level and number of journals). When each is read in I assign new variables we'll call 'MC_Level" and "Num_JRNLS" and some applicable character string values applicable for all data in that data set. I then sort and merge them all into one dataset. For example, the first data set read might have the common fields and each record has a variable "MC_Level" assigned the value 'V03' and a variable "Num_RNLS" with a value of '1'.

One of the common fields in each dataset is "Test-ID" and there are a number of different values for Test-ID. Other common variables include 'Response_Time," "MBs_Transferred," and "IO_Rate"

So we would have:

     MC_Level     Num_JRNLS     Response_Time     MBs_Transferred     IO_Rate     Test-ID     other fields

     V03                    1                    0.23                    123                         97          F1         

     V03                    1                    0.25                    187                         103        F1

     V03                    2                    0.30                    145                         99          F1

     V04                    1                    0.31                    132                         101        G1

...

The goal eventually is to produce graphs by value of Test_ID for Response_Time * IO_Rate and Response_Time * MB/s_Transferred with one graph for all combinations of data. One graph for Test-ID(F1) would include graphs of response times for MC_Level(V03) with Num_JRNLS of 1,2, and 4 AND the same chart has the MC_Level(V04) lines for 1,2,4 values of Num_JRNLS. A second graph contains just the plot lines for MC_Level(V03) and a third graph contains the values for MC_Level(V04).  Then there are graphs for Num_JRNLS(1) with two lines, one each representing MC_Level(V03) and MC_Level(V04) and so on for NUM_JRNLS(2) and NUM_JRNLS(4).

And this would repeat for each value of Test_ID.

Each graph would be output (ODS) to a unique output file for later inclusion into various papers/presentations.

I want to be able to set the VAXIS for each Test-ID value. For example the Test_ID 'F1' will probably always have Response_Time values under 2.0 while the Test_ID 'BA' may have Response_Time values between 0.1 and 12.0 but we'd consider anything above 4.0 to be an outlier. So the values in the VAXIS statement should be something I can pass as a variable or through a table of some kind. A VREF line may also be inserted and would have to vary based on Test_ID. There will probably be something else added to the graph through Annotate that will vary (a previous question about identifying the 'knee of the curve').

Titles and Footnotes will also have to vary based on Test_ID.

I might also want to set the VAXIS based on the output of PROC MEANS by Test_ID for Min/Mean/Max of Response_Time.

I think my questions are:

     1.     can I put variable names into something like a VAXIS statement rather than specific values?

     2.     can I put variable names into Title statements?

     3.     can a PROC PLOT make reference to array elements (placing the footnote, vaxis values etc. into arrays might be more efficient as a means of passing those values)?

I'm thinking the logic of this might be to read the various data sets in and give each record in each data set some assigned values for variables like 'Resp_Time_Upper_Limit'

Sort by Test-ID     MC_Level     Num_JRNLS

if first.Test_id     call a macro     (%PLOT_TESTID)     to build a plot with all values of the Test_ID regardless of MC_Level and Num_JRNLS

if first.MC_Level     call               (%PLOT_MC_level)     plot values for all Num_JRNLS values in the MC_Level

if first.Num_JRNLS     call          (%PLOT_JRNLS)          plot values for that value of Num_JRNLS across values of MC_Level

Okay, sounds like I'm asking for a lot of help. I'm not, and please don't spend much time trying to code it for me. Answering the three questions and maybe an example for those answers is more than enough. I don't want to abuse anyone's time and generosity.


1 REPLY 1
Tom
Super User Tom
Super User

Not sure I followed all of that.  I looks like you want to produce separate graphs for subsets of the data. (where TESTID='F1') and that the code that generates the graph (VAXIS and perhaps other commands?) vary based on the type of test.

You probably at minimum want a macro that takes the TESTID value as an input.  It can then generate the proper VAXIS statement based on the value of TESTID.

Once you have that there are a number of examples out there for generating macro calls for all distinct values in an input dataset.  One simple way is to use PROC SQL to generate the macro calls into a macro variable.

proc sql noprint ;

  select distinct cats('%plot_testid(',test_id,')')

     into :runit separated by ';'

    from mydata

   ;

quit;

&runit ;


sas-innovate-2024.png

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.

 

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
  • 1 reply
  • 336 views
  • 0 likes
  • 2 in conversation