02-22-2018 04:43 PM - edited 02-22-2018 04:46 PM
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);
02-22-2018 04:47 PM
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.
02-22-2018 05:04 PM - edited 02-22-2018 05:04 PM
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.
02-22-2018 04:50 PM
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.
02-22-2018 05:38 PM
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.
02-22-2018 06:24 PM
I had not thought of using an X-axis table, but it sounds like @DanH_sas 's idea is right on target.
02-27-2018 03:51 PM
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.