Search code examples
timesaslinegraphx-axis

x-axis should be time-proportional in SAS


I need to present a linear x-axis, which means that distance between timepoints needs to be time-proportional. I have done the following code:

/*Produce mean +/- SD plot with line graph*/
proc sgplot data=adpc;
vline hours /response=value group=dose stat=mean limitstat=stderr;
xaxis label='Hours post dose';
yaxis label='Mean +/- SD';
run;

This is the output: enter image description here The x-axis has the variable hours which takes the values 0,1,2,3,4,6,8,24 (hours). I think to be time-proportional, means that it should have equal range between the observations. For example, x-axis should be 0,2,4,6,8,10,12,14,16,18,20,22,24 (not sure what time-proportional means). what should i add?


Solution

  • Have you tried specifying the values in the XAXIS statement explicitly?

    You'll need to list them all but this should give you the idea:

    xaxis label='Hours post dose' values = ("0" "2" "4" "6" "8" "10" "12" ... "24");
    

    EDIT: this more simplified version using the fake data from @Joe works well.

    data adpc;
    call streaminit(7);
    do dose = 1,5,10,100;
        do _i = 1 to 100;
            hours = rand('Integer',1,8);
            if hours in (5,7) then hours=24;
            value = rand('Uniform')*100*log(dose+1);
            output;
        end;
    end;
    run;
    
    proc sgplot data=adpc;
    vline hours /response=value group=dose stat=mean limitstat=stderr;
    xaxis label='Hours post dose' values = (0 to 24 by 2);
    yaxis label='Mean +/- SD';
    run;