BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sarahsasuser
Quartz | Level 8

Hi All,

I am working on some graphs and getting a funky result with sgplot. I'm plotting fecal results by day. Most subjects have 0 fecal culture at day 1, but when I add in the subject with >0 fecal culture, sgplot creates a diagonal line. Graph 1 shows that one subject has a fecal culture of 3 and instead of dropping to 0 on the rest of the days as is in the dataset, sgplot draws a diagonal line. Graph 2 shows how this subject's results should be shown. How do I force sgplot to represent the true values for this subject? I have tried to set 0 values to 0.1 for this subject and get the same results. I also do not want to take out this subject from the graph.

Thanks,

Sarah


graph1.pnggraph2.png
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Yes, give the same line color attribute to all lines with LINEATTRS. You might also want to add NOAUTOLEGEND to prevent the production of a meaningless legend :

proc sort data=myData; by subject day; run;

proc sgplot data=myData noautolegend;

series y=CFU x=day / group=subject lineattrs=(color=darkblue);

run;

PG

PG

View solution in original post

5 REPLIES 5
Reeza
Super User

Can you post your code as well, possibly some sample data?

Is your data sorted by anything?

PGStats
Opal | Level 21

Your code should have the following structure:

proc sort data=myData;

by subject day;

run;

proc sgplot data=myData;

series y=CFU x=day / group=subject;

run;

PG

PG
sarahsasuser
Quartz | Level 8

Thanks PGStats, that worked to get rid of the diagonal. However, is there a way to make the groups all one color? There are >30 subjects and 30 color and line combinations.

Thanks,

Sarah

PGStats
Opal | Level 21

Yes, give the same line color attribute to all lines with LINEATTRS. You might also want to add NOAUTOLEGEND to prevent the production of a meaningless legend :

proc sort data=myData; by subject day; run;

proc sgplot data=myData noautolegend;

series y=CFU x=day / group=subject lineattrs=(color=darkblue);

run;

PG

PG
ballardw
Super User

With that many groups I might be tempted to go to SGPanel an produce multiple graphs as you may not be able to tell which values are obscured by lines tracing over one another especially with lots of integer values.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2084 views
  • 3 likes
  • 4 in conversation