Hi everyone. I am trying to add timepoints on my graph for different dates. The dates are in my output data as different columns. I am trying to have timepoints (Jan03, Jan10, etc.) as different points on the X axis and the y axis be the different strains. This is the code I have right now but is only populating a graph with a line for 2 strains and only one time point (Jan03). I would like graph that has lines for each strain (20+) and a point on the graph for every time point so that I can graph this relative growth. Any advise is helpful. Thanks!
Code:
data relgrowth;
set work.company;
Jan03 = week1*100;
Jan10 = week2*100;
Jan17 = week3*100;
Jan24 = week4*100;
drop week1 week2 week3 week4;
run;
proc sgplot data=relgrowth;
series x=Jan03 y=strain;
series x=Jan10 y=strain;
run;
If you want a graph that connects multiple y values for different x values then the data is ONE variable for X and another variable for the y axis. Then the series connects them. An actual date valued variable would make sense.
You mention "relative growth". What variable indicates the growth? Strain sounds like a category and would recommend graphing the "growth" variable with Strain as a group to create different lines for each. Even if you could show multiple "strain" values for the week, they would all be the same given any observation.
At this point I suggest best would be show examples of your entire data set as you need help reshaping the data to have one X axis variable and something for the y
Hi, thanks for the response! I attached the Excel of the data I am testing this with. For the X, I am looking to plot values every week which is where I am getting the Jan03, Jan10, etc. The values on the Excel are all relative growth percentages that have been already calculated. The first column, 'strains', are what I am looking to have as my y axis. I am attaching something as a visual of what I am trying to get. Each strain can be a different colored line with points of its relative risk vs. time point. Please let me know if this clarifies.
x=time point
y=relative growth
and the strains (20+) will be organized on the plot by color
No data appears to be attached.
Your description, and to be anything like the picture in the document attached, the Relative growth percentage would be your Y axis, not strain. Strain would be group variable.
Still can't see how that "week" stuff works as no spread sheet attached and would reshape the data so your values are like
Strain RelativeGrowth WeekNumber (or actual date)
Note, in general spreadsheets are poor instruments for data interchange because 1) users often violate good data normalization practices (in this case multiple columns for the same data with actual data in the column heading) and 2) cells have no constraints as to data types, resulting in columns mixing numeric character and other forms of data.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.