BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

Dear all,

I have a question about I created a swimmer plot with this dataset:

 

 

data test;                                                                                                                 
input pat_id 2.	startline1 5.	endline1 5. startline2	5. endline2 5. status 6. startyear 5. diagnosisyear 5. lastfollowup 5.;
datalines;                                                                                                                 
1  2000 2011 2000 2011                                                                                     
2  2001 2010 2010 2010 -0.25 2001 2010 2010                                                                                
3  2002 2019                 2002 2019                                                                                     
4  2003 2009 		     2003 2009                                                                                     
5  2004 2013 2019 2019       2004 2013 2019                                                                                
6  2005 2014 2018 2018       2005 2014 2018                                                                                
7  2006 2015 2018 2018       2006 2015 2018                                                                                
8  2007 2007 		     2007 2007                                                                                     
9  2008 2015 2017 2017       2008 2015 2017                                                                                
10 2009 2012 2017 2017 -0.25 2009 2012 2017                                                                                
11 2010 2016 		     2010 2016                                                                                     
12 2011 2015 		     2011 2015                                                                                     
13 2012 2020 2020 2020 -0.25 2012 2020  2020                                                                               
14 2013 2016                 2013 2016                                                                                     
;                                                                                                                          
run;         

 

 

proc sgplot data= test noautolegend;

hbarparm category = pat_id response=diagnosisyear /  barwidth=0.5;

highlow y=pat_id low=startline1 high=endline1 / lineattrs=(thickness=2 pattern=solid color=blue);
highlow y=pat_id low=startline2 high=endline2 / lineattrs=(thickness=2 pattern=solid color=darkred) ;

yaxis type=discrete display=(nolabel);
xaxis grid type=linear display=(nolabel) values=(2000 to 2020 by 1);

scatter y=pat_id x=startyear  /markerattrs=(symbol=trianglefilled size=9 color=yellow) name="a" legendlabel="start-year";
scatter y=pat_id x=diagnosisyear /markerattrs=(symbol=circlefilled size=9 color=green) name="b" legendlabel= "Diagnosis-year";
scatter y=pat_id x=lastfollowup  /markerattrs=(symbol=squarefilled size=9 color=pink) name="c" legendlabel= "Last fpllowup";
scatter y=pat_id x=status  /markerattrs=(symbol=starfilled size=9 color=black) name="d" legendlabel= "Status";

Keylegend "a" "b" "c" "d" / noborder location=outside position=topright across=0;
run;

my problem is I want the status to be displayed as the example on graphically speaking like the "durable responder" is displayed but I can't get it working. Any help?

3 REPLIES 3
ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

Anita_n
Pyrite | Level 9

Dear all,

I have changed the excel sheet to a datastep. I will appreciate any help

Anita_n
Pyrite | Level 9

I realised that my x-axis starts from 2000 to 2020 that is maybe why the  minus 0.25 cannot be displayed. Any idea how I can solve this?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 455 views
  • 0 likes
  • 2 in conversation