BookmarkSubscribeRSS Feed
LOLO12
Obsidian | Level 7

Hi All, 

I have difficulties getting some graphs rights. I'm not familiar with do loops and macro with sgplot. 

I need to output the scatter plots, the slope and the slope value, and the point of change on the x axis. 

 

this is a sample of the data and code below

 

Spoiler
data example; 
input usubjid $ trta $ param $ paramn parcat3n avision value intercept slope x_axis_value; 
datalines;
1 A Vertical(D)  1 -0.2 2 0.1707 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 -0.2 2 -0.0669 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 -0.2 2 0.1521 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 -0.2 2 -0.0992 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 -0.41 2 -0.0714 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 -0.41 2 0.1811 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 -0.41 2 0.0141 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 -0.41 2 -0.1178 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0     2 -0.1262 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0     2 -0.0793 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0     2 0.0298 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0     2 0.1851 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.2     2 -0.0253 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.2     2 0.1388 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.2     2 0.6125 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.2     2 -0.0559 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.41 2 -0.0255 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.41 2 -0.1386 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.41 2 0.3035 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.41 2 0.0774 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.61 2 0.0726 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.61 2 -0.1511 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.61 2 -0.2065 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.61 2 0.2805 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.81 2 0.1613 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.81 2 0.3675 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.81 2 0.2     0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 0.81 2 0.0016 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.02 2 0.1792 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.02 2 0.2991 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.02 2 0.3813 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.02 2 0.2411 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.22 2 0.2553 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.22 2 0.2884 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.22 2 0.7136 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.22 2 -0.0152 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.43 2 0.4232 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.43 2 0.448 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.43 2 0.2378 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.43 2 0.5496 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.63 2 0.5702 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.63 2 0.6     0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.63 2 0.6161 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.63 2 0.4157 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.83 2 1.0329 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.83 2 0.5851 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.83 2 0.6626 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 1.83 2 0.7523 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.04 2 0.7635 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.04 2 0.7686 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.04 2 0.9049 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.04 2 0.6882 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.24 2 0.8305 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.24 2 0.9262 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.24 2 0.8935 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 2.24 2 1.3591 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.44 2 1.0929 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.44 2 1.5478 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.44 2 1.0488 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.44 2 0.7817 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 2.65 2 1.1285 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 2.65 2 1.2927 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 2.65 2 1.2595 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.65 2 0.9924 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.85 2 1.4696 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.85 2 0.2935 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.85 2 0.7271 0.935899949 -0.390958784 2.447266353
1 A Vertical(D) 1 2.85 2 1.3147 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 3.06 2 1.4319 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)  1 3.06 2 0.1533 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 3.06 2 1.3206 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)  1 3.06 2 0.9575 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 3.26 2 0.0014 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)  1 3.26 2 1.6503 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)     1 3.26 2 0.5574 0.935899949 -0.390958784 2.447266353
1 A Vertical(D)  1 3.26 2 0.424 0.935899949 -0.390958784 2.447266353
1 A Horizontal(D) 2 -0.21 1 0.1448 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.21 1 -0.375 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.21 1 0.3902 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.21 1 -0.2554 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.41 1 0.2108 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.41 1 -0.5052 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.41 1 -0.409 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 -0.41 1 -0.8127 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0     1 0.0268 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0     1 -0.1181 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0     1 0.339 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0     1 -0.2461 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.21 1 -0.289 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.21 1 0.0428 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.21 1 0.3737 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.21 1 0.3882 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.41 1 -0.0451 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.41 1 -0.2725 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.41 1 0.2029 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.41 1 0.4177 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.62 1 0.1691 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.62 1 -0.1687 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.62 1 -1.0771 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.62 1 0.2388 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.83 1 0.3029 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.83 1 0.5051 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.83 1 -0.9407 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 0.83 1 0.3464 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.04 1 0.1285 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.04 1 0.2376 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.04 1 0.5279 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.04 1 -0.3623 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.25 1 -0.0329 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.25 1 0.3425 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.25 1 -0.6584 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.25 1 -0.3581 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.45 1 0.4022 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.45 1 0.3429 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.45 1 0.3076 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.45 1 -0.489 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.66 1 0.3751 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.66 1 0.3222 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.66 1 -0.0473 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.66 1 0.3665 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.87 1 0.4804 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.87 1 0.3097 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.87 1 -0.2533 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 1.87 1 -0.06 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.08 1 0.3615 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.08 1 -1.1145 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.08 1 -0.1673 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.08 1 -0.8939 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.28 1 0.3122 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.28 1 0.6135 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.28 1 -0.7456 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.28 1 0.6849 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.49 1 0.5677 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.49 1 -0.2066 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.49 1 0.0414 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.49 1 -0.5632 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.7     1 0.5773 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.7     1 0.5452 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.7     1 -0.1142 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.7     1 0.3945 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.9    1 0.6845 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.9     1 0.5298 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.9     1 -1.3461 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 2.9     1 0.2105 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.11 1 0.3965 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.11 1 0.6605 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.11 1 -0.4938 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.11 1 0.1051 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.32 1 0.3853 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.32 1 0.7322 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D) 2 3.32 1 -0.9426 0.04885302 -1.775846127 -0.169060756
1 A Horizontal(D)   2 3.32 1 0.0293 0.04885302 -1.775846127 -0.169060756
1 B Accommodat(D) 3 -0.21 1 0.1003 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.21 1 -0.0665 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.21 1 0.3441 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.21 1 0.1783 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.41 1 0.3098 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.41 1 0.3597 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.41 1 0.372 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 -0.41 1 -0.0616 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0     1 -0.0624 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0     1 0.0836 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0     1 -0.1015 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0     1 0.0816 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.21 1 0.405 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.21 1 -0.0232 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.21 1 0.0284 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.21 1 0.1742 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.41 1 -0.0602 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.41 1 -0.0133 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.41 1 0.2819 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.41 1 0.1425 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.62 1 -0.1619 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.62 1 0.0271 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.62 1 -0.2757 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.62 1 0.238 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.83 1 0.0424 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.83 1 0.0348 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.83 1 0.2973 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 0.83 1 0.0949 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.04 1 0.0922 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.04 1 -0.0785 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.04 1 -0.3258 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.04 1 -0.1451 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.25 1 -0.2052 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.25 1 0.0582 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.25 1 0.0577 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.25 1 0.0193 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.45 1 -0.2301 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.45 1 0.1912 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.45 1 0.292 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.45 1 0.0001 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.66 1 0.2386 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.66 1 0.1388 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.66 1 0.1483 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.66 1 0.034 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.87 1 -0.0221 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.87 1 0.0838 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.87 1 0.369 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 1.87 1 0.2857 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.08 1 -0.1323 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.08 1 0.2017 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.08 1 0.2523 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.08 1 0.0167 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.28 1 0.0078 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.28 1 0.1426 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.28 1 0.3908 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.28 1 0.1036 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.49 1 0.3323 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.49 1 0.1939 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.49 1 -0.2569 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.49 1 0.1658 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.7     1 -0.0026 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.7     1 0.4685 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.7     1 0.0036 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.7    1 0.5123 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.9  1 0.2968 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.9 1 0.3871 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.9 1 0.055 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 2.9     1 0.0564 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.11 1 -0.1342 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.11 1 0.1774 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.11 1 0.5596 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.11 1 0.5958 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.32 1 0.444 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.32 1 -0.0021 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.32 1 0.0103 0.107655911 0.529623822 -0.150723888
1 B Accommodat(D) 3 3.32 1 0.2388 0.107655911 0.529623822 -0.150723888
;
run; 

proc sgplot data=example noautolegend;
by paramn param avision trta usubjid;
   scatter  x=parcat3n y=value / group=trta groupdisplay=cluster clusterwidth=0.5
markerattrs=( size=10)errorbarattrs=(thickness=2); 
    styleattrs datasymbols=(circle);
    yaxis  label='Aval (D)' grid  values=(-7.25 to 7.25 by .25);
xaxis   offsetmax=0.08 fitpolicy=rotate   
    values=(-0.41 -0.2 0 0.2 0.41 0.61 0.81 1.02 1.22 1.43 1.63 1.83 2.04 2.24 2.44 2.65 2.85 3.06 3.26);  
    keylegend / title="Treatment" ;
run;
 

please don't remove this topic. this is not scam 

11 REPLIES 11
PaigeMiller
Diamond | Level 26

Please show us the plots you are getting (use the "Insert Photos" icon to include screen captures in your reply; DO NOT attach files) and explain exactly what is wrong with them.

 

For your future benefit, saying things like "I have difficulties getting some graphs rights" or more generally "It doesn't work" without further explanation is never sufficient.

--
Paige Miller
LOLO12
Obsidian | Level 7

I'm not able to output the accurate estimates values on the graph. Also, I don't know how to display the slope 

Please try this code and you will understand the issue. the graph suppose to show the corresponding slope value instead it rad the second raw in the slope for the second graph. 

data _null_;
   set example;
   if _n_ = 1 then call symput('Int', put(intercept, BEST6.));    
   else            call symput('Slope', put(slope, BEST6.));  
run;
 
proc sgplot data=example noautolegend;
by paramn param avision trta usubjid;
   scatter  x=parcat3n y=value / group=trta groupdisplay=cluster clusterwidth=0.5
markerattrs=( size=10)errorbarattrs=(thickness=2); 
    styleattrs datasymbols=(circle);
    yaxis  label='Aval (D)' grid  values=(-7.25 to 7.25 by .25);
xaxis   offsetmax=0.08 fitpolicy=rotate   
    values=(-0.41 -0.2 0 0.2 0.41 0.61 0.81 1.02 1.22 1.43 1.63 1.83 2.04 2.24 2.44 2.65 2.85 3.06 3.26);
    refline x_axis_value / axis=x lineattrs=(color=red thickness=3px
 pattern=ShortDashDot); 
   inset "Intercept = &Int" "Slope = &Slope" / 
         border title="Parameter Estimates" position=topleft;
    keylegend / title="Treatment" ;
run;
mona12_0-1688674660966.png

 

PaigeMiller
Diamond | Level 26

I'm not able to output the accurate estimates values on the graph.

 

What is stopping you? Accurate in what sense? What numbers do you want to see on this graph?

 

Also, I don't know how to display the slope

 

You have displayed the slope. It says Slope = 0.5296

--
Paige Miller
LOLO12
Obsidian | Level 7

for the first graph the value is correct then for the second graph it displays the same value for the first graph. Something has to do with the macro. it is not reading the right slope value it is reading the second raw in the data which is the value of the first graph. 

PaigeMiller
Diamond | Level 26

Show me the code in which the macro variables are created.

--
Paige Miller
LOLO12
Obsidian | Level 7
it is in my comment above ^^^
PaigeMiller
Diamond | Level 26

You haven't shown me the DO-loop where this will be used.

--
Paige Miller
Reeza
Super User
%macro create_graph(_paramn=, _param=, _avision=, _trta=, _usubjid=);
    data _null_;
        set example (obs=1);
        where paramn=&_paramn. & param="&_param." & avision=&_avision. & trta="&_trta." & usubjid="&_usubjid.";
        call symput('Int', put(intercept, BEST6.));
        call symput('Slope', put(slope, BEST6.));
    run;

    proc sgplot data=example noautolegend;
        where paramn=&_paramn. & param="&_param." & avision=&_avision. & trta="&_trta." & usubjid="&_usubjid.";
        scatter x=parcat3n y=value / group=trta groupdisplay=cluster clusterwidth=0.5 
            markerattrs=(size=10)errorbarattrs=(thickness=2);
        styleattrs datasymbols=(circle);
        yaxis label='Aval (D)' grid values=(-7.25 to 7.25 by .25);
        xaxis offsetmax=0.08 fitpolicy=rotate values=(-0.41 -0.2 0 0.2 0.41 0.61 0.81 
            1.02 1.22 1.43 1.63 1.83 2.04 2.24 2.44 2.65 2.85 3.06 3.26);
        refline x_axis_value / axis=x lineattrs=(color=red thickness=3px 
            pattern=ShortDashDot);
        inset "Intercept = &Int" "Slope = &Slope" / border 
            title="Parameter Estimates" position=topleft;
        keylegend / title="Treatment";
    run;

%mend;

data test;
    set example;
    by paramn param avision trta usubjid NOTSORTED;

    if first.usubjid then
        do;
            str=catt('%create_graph(_paramn=', paramn, ", _param=", param, 
                " , _avision=", avision, ", _trta= ", trta, ", _usubjid=", %str(usubjid), 
                ');');
            rc=dosubl(str);
            output;
        end;
run;
LOLO12
Obsidian | Level 7

Hi Reeza, 

The solution worked however I still got one more problem when I try to display the slope. It is not showing the correct intercept value not sure what is the issue. this is the figure and the code that I'm trying 

 

mona12_0-1688773071256.png

 

 

 
%macro create_graph(_paramn=, _param=, _avision=, _trta=, _usubjid=);
    data _null_;
        set example (obs=1);
        where paramn=&_paramn. & param="&_param." & avision=&_avision. & trta="&_trta." & usubjid="&_usubjid.";
        call symput('Int', put(intercept, BEST6.));
        call symput('Slope', put(slope, BEST6.));
    run;
title " &_param &_avision &_trta &_usubjid";
    proc sgplot data=example noautolegend;
        where paramn=&_paramn. & param="&_param." & avision=&_avision. & trta="&_trta." & usubjid="&_usubjid.";
        scatter x=parcat3n y=value / group=trta groupdisplay=cluster clusterwidth=0.5 
            markerattrs=(size=10)errorbarattrs=(thickness=2);
        styleattrs datasymbols=(circle);
        yaxis label='Aval (D)' grid values=(-7.25 to 7.25 by 0.25);
        xaxis offsetmax=0.08 fitpolicy=rotate values=(-0.41 -0.2 0 0.2 0.41 0.61 0.81 
            1.02 1.22 1.43 1.63 1.83 2.04 2.24 2.44 2.65 2.85 3.06 3.26);
        refline x_axis_value / axis=x lineattrs=(color=red thickness=3px 
            pattern=ShortDashDot);
        inset "Intercept = &Int" "Slope = &Slope" / border title="Parameter Estimates" position=topleft;
lineparm   x=0 y=intercept slope=Slope; 
        keylegend / title="Treatment";
    run;
 
%mend;
 
data test;
    set example;
    by paramn param avision trta usubjid NOTSORTED;
    if first.usubjid then
        do;
            str=catt('%create_graph(_paramn=', paramn, ", _param=", param, 
                " , _avision=", avision, ", _trta= ", trta, ", _usubjid=", %str(usubjid), 
                ');');
            rc=dosubl(str);
            output;
        end;
run;

 

PaigeMiller
Diamond | Level 26

If the intercept and slope are from a linear regression on the data, then the values of slope and intercept in your original data are not correct.

 

proc reg data=example plots=none;
    by trta notsorted param;
    model value=parcat3n;
run;

 

 

--
Paige Miller
Reeza
Super User
Am I missing the question?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1694 views
  • 6 likes
  • 3 in conversation