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

How can I recreate this gplot procedure using sgplot?

symbol1 v=M i=sm70 c=black l=1;
symbol2 v=S i=sm70 c=black l=3;
proc gplot data=insurance;
   plot months*size=stock;
run;
proc sgplot data=insurance; 
	pbspline x=stock y=months*size; 

I tried using the above sgplot procedure but gave me errors because SAS UE does not recognize the "months*size" part from the former gplot procedures. I need two fitted lines within the graph because the stocks are binary 0 or 1.

Capture.GIFCapture.GIF

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Super User

You could also use the PBSPLINE statement as you initially intended, still group by stock and use a high value for the SMOOTH option like this

 

data insurance;
input months size stock;
datalines;
30 31  0
26 92  0
22 104 0
19 120 0
17 151 0
21 175 0
12 210 0
16 238 0
0  277 0
4  290 0
38 68  1
31 85  1
30 124 1
28 164 1
20 166 1
21 224 1
14 246 1
15 272 1
11 295 1
13 305 1
;

title 'Insurance Innovation';
title2 'With Smoothed Lines';
proc sgplot data = insurance;
   pbspline x = size y = months / group=stock smooth = 1000000;
   yaxis min=0 max=40;
   xaxis min=0 max=400;
run;

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

 

 

proc sgplot data=insurance;
  reg x=size y=month / group=stock;
run;
Thanks,
Jag
syk
Obsidian | Level 7 syk
Obsidian | Level 7
What about the individual line attributes? How can I customize the lines with the group procedure? Also I need a fitted line to determine the initial correlation not a straight fitted line. The loess feature worked better.
PeterClemmensen
Super User

You could also use the PBSPLINE statement as you initially intended, still group by stock and use a high value for the SMOOTH option like this

 

data insurance;
input months size stock;
datalines;
30 31  0
26 92  0
22 104 0
19 120 0
17 151 0
21 175 0
12 210 0
16 238 0
0  277 0
4  290 0
38 68  1
31 85  1
30 124 1
28 164 1
20 166 1
21 224 1
14 246 1
15 272 1
11 295 1
13 305 1
;

title 'Insurance Innovation';
title2 'With Smoothed Lines';
proc sgplot data = insurance;
   pbspline x = size y = months / group=stock smooth = 1000000;
   yaxis min=0 max=40;
   xaxis min=0 max=400;
run;
syk
Obsidian | Level 7 syk
Obsidian | Level 7
How do I customized individual line attributes? ex) one line to be solid and one to be dotted.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 717 views
  • 0 likes
  • 3 in conversation