Hi,
I have a data set where essentially all variables are numeric and I would like to plot one variable (i.e., SScsem's listed below) as the y-variable and specify two other variables as the x-axis. The variables for the x-axis have a one-to-many relationship - one is a linear transformation of the other (the two scales have different properties so it would be best to use both for the x-axis).
My basic code is below (work-in-progress).
Any idea if SAS allows for this type of feature?
proc sgplot data=allCSEM;
series x=x y= SScsem_K0/LINEATTRS=(color=black) ;
series x=x y= SScsem_K02/LINEATTRS= (color=red);
series x=x y= SScsem_K03/LINEATTRS= (color=blue);
series x=x y= SScsem_K04/LINEATTRS= (color=green);
series x=x y= SScsem_K05/LINEATTRS= (color=orange);
series x=x y= SScsem_K06/LINEATTRS= (color=purple);
run;
Presumably you only want one displayed? If so, why not just use that one? You can use an X2 axis. You don't have to display any ticks or anything. If you want that perfect correspondence between the two axes, you have to resort to some trickery as I recall. I know I have done that before with GTL. I think I have done it with SGPLOT too. Let me see if I can remember where.
Thank you for your response but I would like both values for the x-axis displayed - each of which correspond to a variable in the data set. An example of what my data look like is below - maybe this helps clarify what I'd like.
x1 x2 y1 .... up to y8
1 118 .52
2 118 .53
3 119 .60
4 120 .62
5 120 .69
6 121 .78
7 121 .82
...
I'd need to be able to display both the x1 and x2 values along the x-axis.
This should work. Are you getting the graph you expect? You could also use a GROUPED data structure, and then you need only one SERIES statement with GROUP option.
My graph looks like what I want except I don't have the second x-axis that I need. I just briefly read the grouped option and I don't think I want to group my data. I'm not sure though. Do yo have an example? I explained my data structure a little better in a response above - perhaps that might help clarify what I'd like to achieve.
Try putting your second X variable in an XAXISTABLE and see if you get what you want.
I had not thought of using an X-axis table, but it sounds like @DanH_sas 's idea is right on target.
https://blogs.sas.com/content/graphicallyspeaking/?s=axis+tables
I put my second x-axis variable (labeled "SS") in an xaxistable and it appears on the graph however, there are too many repeat values such that all the numeric values are blurred into one long incoherent string. Are there options such as "xaxis values=(118 to 132 by 2);" (as an example) that can be used with xaxistables? I cannot seem to format this secondary axis at all. My variables are all numeric, if that matters.
I am not confident the xaxistable will solve this issue based on the limited number of option statements associated with it.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.