I want to have the following timepoints labelled: Days 1, 6, 8, day of treatment, day of treatment plus 7 with non-uniform spacing.
I have the following code:
title1 "Subject &id.";
proc sgpanel data= &dsn. noautolegend;
where usubjid= "&id." and paramcd = "¶m.";
panelby aphase / novarname columns= 4;
series x= stdy y= chg;
scatter x= stdy y= chg;
styleattrs
datacontrastcolors= (red blue orange green)
datalinepatterns= (solid);
colaxis min= 1 max= 18 values= (1 6 8 &T. &T7.) valuesdisplay= ("1" "6" "8" "T" "T+7") label= "Actual CHMI Day";
rowaxis min= 0 max= 50 values= (0 to 50 by 5) label= "Antibody Reactivity (Baseline-adjusted OD^{unicode '2082'x}410)";
run;
My problem is not everyone was treated on the same day for each CHMI. Is there a way to reference a specific variable within the dataset to use in the axis?
Data have:
data have;
input usubjid $ phase $ stdy paramcd $ chg trtdy1 trtdy2 @@;
cards;
A CHMI1 1 IgG -0.794 . .
A CHMI1 2 IgG -0.854 . .
A CHMI1 3 IgG -0.822 . .
A CHMI1 4 IgG -0.724 . .
A CHMI1 5 IgG -0.765 . .
A CHMI1 6 IgG -0.721 . .
A CHMI1 7 IgG -0.605 . .
A CHMI1 8 IgG -0.557 . .
A CHMI1 9 IgG -0.421 . .
A CHMI2 1 IgG 0.489 . .
A CHMI2 2 IgG 0.211 . .
A CHMI2 3 IgG 0.089 . .
A CHMI2 4 IgG -0.121 4 11
A CHMI2 5 IgG -0.150 4 11
A CHMI2 6 IgG -0.268 4 11
A CHMI2 7 IgG -0.279 4 11
A CHMI2 8 IgG -0.226 4 11
A CHMI2 9 IgG -0.112 4 11
A CHMI2 10 IgG -0.025 4 11
A CHMI2 11 IgG -0.079 4 11
A CHMI3 1 IgG -0.014 9 .
A CHMI3 2 IgG -0.028 9 .
A CHMI3 3 IgG -0.112 9 .
A CHMI3 4 IgG -0.186 9 .
A CHMI3 5 IgG -0.101 9 .
A CHMI3 6 IgG -0.026 9 .
A CHMI3 7 IgG 0.082 9 .
A CHMI3 8 IgG 0.052 9 .
A CHMI3 9 IgG 0.106 9 .
A CHMI3 10 IgG 0.044 9 .
A CHMI3 11 IgG -0.025 9 .
A CHMI3 12 IgG -0.111 9 .
;
run;
Are you trying to force specific values to become new coordinates for the plot? Which variables to which value on which row?
With a series plot use of the actual value just means that you may have "bends" in the line in places that don't match the axis tick marks. Nothing wrong with that generally. Series plots mean that the interval between points is important to the presentation, even when irregularly spaced.
However, if you expect all of the values to align with specific tick marks you have to tell us which ones aren't correct and what they need to be changed to or a rule of some sort. It may mean that perhaps you don't actually want a series at all.
You provide code with many macro variables and don't provide any example values. So we can't test your actual values for anything.
Based on the example figure I was given, we want the bends at the specified time points. T is the treatment day and T+7 is seven days after treatment day, also represented by trtdy1 and trtdy2 in my mock dataset, respectively.
Maybe you need this ?
proc sgscatter data=sashelp.iris;
title "Iris Data: Length and Width";
compare x=(sepallength petallength)
y=(sepalwidth petalwidth)
/ group=species join;
run;
proc sgscatter data=sashelp.iris(where=(species="Virginica")); title "Multi-Celled Spline Curve for Species Virginica"; plot (sepallength sepalwidth)*(petallength petalwidth) / join; run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.