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

Hi all,

Thanks so much for helping me through some of the procedures. I have my data in excel and I am looking to plot baseline and end of training line graph for 7 characteristics of interest. I have 18 subjects so I need individual line graphs for each of the 18 subjects and the average (overall) baseline and end of training line graph. Of the 7 characteristics, I want to plot at least 3-4 in one graph and rest in other.

 

Subject_ID - has individual IDs and Overall

HRM- has my characteristics of interest

Baseline- baseline value

End- End of training value

 

So I need 18 lines in different shade and overall (average) line in a darker or a thick shade.

 

I have attached an example PPT of what I am looking for.example.jpg

 

So basically the goal of the graph is to show there is an upward trend/ improvement after the training.

 

Any help with SAS code or references would be of great help.

 

Thank you all,

Sat

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You should post it at ODS Graphic forum.

 

 


data have;
infile cards expandtabs truncover;
input Subject_ID :$40. HRM :$40. Baseline	End;
vname='Baseline';value=Baseline;output;
vname='End';value=End;output;
drop baseline end;
cards;
2531176	Achalasia_obstructio 	60	100
2941226	Achalasia_obstructio 	60	100
2946145	Achalasia_obstructio 	40	80
4070061	Achalasia_obstructio 	60	100
4071502	Achalasia_obstructio 	40	80
4072576	Achalasia_obstructio 	60	100
4073464	Achalasia_obstructio 	50	80
4075018	Achalasia_obstructio 	80	90
4076717	Achalasia_obstructio 	40	100
4077019	Achalasia_obstructio 	60	140
4077142	Achalasia_obstructio 	60	100
4077188	Achalasia_obstructio 	80	100
4077945	Achalasia_obstructio 	80	100
4077972	Achalasia_obstructio 	80	100
4078140	Achalasia_obstructio 	100	180
4078395	Achalasia_obstructio 	100	100
4079303	Achalasia_obstructio 	40	100
4076742	Achalasia_obstructio 	80	100
Overall	Achalasia_obstructio 	65.9	90.6
2531176	EGJmanagement 	60	100
2941226	EGJmanagement 	60	100
2946145	EGJmanagement 	40	80
4070061	EGJmanagement 	60	100
4071502	EGJmanagement 	40	80
4072576	EGJmanagement 	60	100
4073464	EGJmanagement 	80	86
4075018	EGJmanagement 	80	100
4076717	EGJmanagement 	40	100
4077019	EGJmanagement 	60	90
4077142	EGJmanagement 	60	100
4077188	EGJmanagement 	80	100
4077945	EGJmanagement 	80	100
4077972	EGJmanagement 	80	100
4078140	EGJmanagement 	100	180
4078395	EGJmanagement 	100	100
4079303	EGJmanagement 	40	100
4076742	EGJmanagement 	80	100
Overall	EGJmanagement 	65.9	90.6
;
run;

data want;
 merge have(where=(subject_id ne 'Overall'))
  have(rename=(subject_id=id vname=b value=d) where=(id eq 'Overall'));
 by hrm;
 output;
 call missing(of _all_);
run;
proc sgpanel data=want;
 panelby hrm/ layout=columnlattice colheaderpos=bottom noborder novarname;
 series x=vname y=value/group=subject_id  lineattrs=graphdata1;
 series x=b y=d/lineattrs=graphdata2(thickness=4px) name='x' legendlabel='Overall';
 keylegend 'x' / position=top ;
 colaxis label=' ';
run;

 

 

 

x.png

View solution in original post

9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, I won't download XLSX files, post test data in the form of a datastep.

 

For your graph, this should be very simple:

proc sgplot data=<your dataset>;
  series y=<var> x=<var>;
  series y=<var> x=<var>;
...
run;

Note there are a vast amount of options you can apply to graphs, and many statements.  Here is a site which gives you lots of advice:

http://blogs.sas.com/content/graphicallyspeaking/

smunigala
Obsidian | Level 7

Thanks for the reply. Here is the data:

 

Subject_ID HRM Baseline End
2531176 Achalasia_obstructio  60 100
2941226 Achalasia_obstructio  60 100
2946145 Achalasia_obstructio  40 80
4070061 Achalasia_obstructio  60 100
4071502 Achalasia_obstructio  40 80
4072576 Achalasia_obstructio  60 100
4073464 Achalasia_obstructio  80 80
4075018 Achalasia_obstructio  80 80
4076717 Achalasia_obstructio  40 100
4077019 Achalasia_obstructio  60 40
4077142 Achalasia_obstructio  60 100
4077188 Achalasia_obstructio  80 100
4077945 Achalasia_obstructio  80 100
4077972 Achalasia_obstructio  80 100
4078140 Achalasia_obstructio  100 80
4078395 Achalasia_obstructio  100 100
4079303 Achalasia_obstructio  40 100
4076742 Achalasia_obstructio  80 100
Overall Achalasia_obstructio  65.9 90.6

 

 

Just like Achalasia_obstructio there are three other variables that I am interested in under HRM Variable which I want to plot  next to Achalasia_Obstruction. Please see my JPEG fig I attached in my original email.

ballardw
Super User

I don't see any JPEG or JPG attachment, only XLSX.

smunigala
Obsidian | Level 7

Here I am attaching the JPEG again as an image.example.jpg


example.jpg
Ksharp
Super User

You should post it at ODS Graphic forum.

 

 


data have;
infile cards expandtabs truncover;
input Subject_ID :$40. HRM :$40. Baseline	End;
vname='Baseline';value=Baseline;output;
vname='End';value=End;output;
drop baseline end;
cards;
2531176	Achalasia_obstructio 	60	100
2941226	Achalasia_obstructio 	60	100
2946145	Achalasia_obstructio 	40	80
4070061	Achalasia_obstructio 	60	100
4071502	Achalasia_obstructio 	40	80
4072576	Achalasia_obstructio 	60	100
4073464	Achalasia_obstructio 	50	80
4075018	Achalasia_obstructio 	80	90
4076717	Achalasia_obstructio 	40	100
4077019	Achalasia_obstructio 	60	140
4077142	Achalasia_obstructio 	60	100
4077188	Achalasia_obstructio 	80	100
4077945	Achalasia_obstructio 	80	100
4077972	Achalasia_obstructio 	80	100
4078140	Achalasia_obstructio 	100	180
4078395	Achalasia_obstructio 	100	100
4079303	Achalasia_obstructio 	40	100
4076742	Achalasia_obstructio 	80	100
Overall	Achalasia_obstructio 	65.9	90.6
2531176	EGJmanagement 	60	100
2941226	EGJmanagement 	60	100
2946145	EGJmanagement 	40	80
4070061	EGJmanagement 	60	100
4071502	EGJmanagement 	40	80
4072576	EGJmanagement 	60	100
4073464	EGJmanagement 	80	86
4075018	EGJmanagement 	80	100
4076717	EGJmanagement 	40	100
4077019	EGJmanagement 	60	90
4077142	EGJmanagement 	60	100
4077188	EGJmanagement 	80	100
4077945	EGJmanagement 	80	100
4077972	EGJmanagement 	80	100
4078140	EGJmanagement 	100	180
4078395	EGJmanagement 	100	100
4079303	EGJmanagement 	40	100
4076742	EGJmanagement 	80	100
Overall	EGJmanagement 	65.9	90.6
;
run;

data want;
 merge have(where=(subject_id ne 'Overall'))
  have(rename=(subject_id=id vname=b value=d) where=(id eq 'Overall'));
 by hrm;
 output;
 call missing(of _all_);
run;
proc sgpanel data=want;
 panelby hrm/ layout=columnlattice colheaderpos=bottom noborder novarname;
 series x=vname y=value/group=subject_id  lineattrs=graphdata1;
 series x=b y=d/lineattrs=graphdata2(thickness=4px) name='x' legendlabel='Overall';
 keylegend 'x' / position=top ;
 colaxis label=' ';
run;

 

 

 

x.png

smunigala
Obsidian | Level 7

Thank you so much. Couple of follow-up questions.

 

1. Can I do three characteristics in one panel?

2. How do I lable (in sas statement) for Achalasia_Obstructio as "Achalasis/ Outflow Obstruction" and EJGManagment as "Management: EGJ"

smunigala
Obsidian | Level 7

One last question...How do I change or control y-axis? I need 0-200 by 20, rather than 0-100 by 10.

 

Thank you,

Sat

ballardw
Super User

The panelby statement has options to specify the number of rows or columns.

 

If the values in your data set are not what you want displayed then often the easiest way is to use a custom format such as

proc format;
value $MyValues
"Achalasia_Obstructio" = "Achalasis/ Outflow Obstruction" 
"EJGManagment" = "Management: EGJ";
run;

And then use a FORMAT statement in the procedure to associate the format with the variable.

 

The ROWAXIS statement controls appearance of the Y axis in SGPANEL.

 

Rowaxis values=( 0 to 200 by 20);

should do the trick.

add label="Some y description" to the Rowaxis if you want a different axis label.

 

Ksharp
Super User

"1. Can I do three characteristics in one panel?"

I don't understand what you mean.Give us an example .

panelby hrm/ layout=columnlattice colheaderpos=bottom noborder novarname  onepanel ;

 

 

Others questions have been answered by @ballardw . You really should post it at ODS Graphic forum.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 9 replies
  • 8990 views
  • 2 likes
  • 4 in conversation