I have 50 patients measured at 3 timepoints (control, baseline, post). The number of variables is greater than 200. Data has vertitical structure:
control
baseline
post
I enclose small part of for illustration (with only 4 variables):
SUBJECT,TIME,VAR1,VAR2,VAR3,VAR4
1,Control ,17.20,18.50,10.10,-6.20
2,Control ,16.30,2.30,8.20,5.00
3,Control ,4.50,4.50,6.30,2.00
4,Control ,8.30,6.30,12.20,7.00
5,Control ,8.80,17.30,7.20,8.50
6,Control ,12.20,2.30,16.00,11.30
7,Control ,6.85,5.11,13.24,14.90
8,Control ,5.60,4.14,14.17,17.84
9,Control ,4.35,3.16,15.09,20.79
10,Control ,3.10,2.18,16.02,23.73
11,Control ,1.85,1.20,16.94,26.67
12,Control ,0.60,0.23,17.87,29.61
13,Control ,-0.64,-0.75,18.79,32.56
14,Control ,-1.89,-1.73,19.72,35.50
15,Control ,-3.14,-2.70,20.65,38.44
16,Control ,-4.39,-3.68,21.57,41.39
17,Control ,-5.64,-4.66,22.50,44.33
18,Control ,-6.89,-5.64,23.42,47.27
19,Control ,-8.14,-6.61,24.35,50.21
20,Control ,-9.38,-7.59,25.27,53.16
21,Control ,-10.63,-8.57,26.20,56.10
22,Control ,-11.88,-9.54,27.13,59.04
23,Control ,-13.13,-10.52,28.05,61.99
24,Control ,-14.38,-11.50,28.98,64.93
25,Control ,-15.63,-12.48,29.90,67.87
26,Control ,-16.88,-13.45,30.83,70.81
27,Control ,-18.12,-14.43,31.75,73.76
28,Control ,-19.37,-15.41,32.68,76.70
29,Control ,-20.62,-16.38,33.61,79.64
30,Control ,-21.87,-17.36,34.53,82.59
31,Control ,-23.12,-18.34,35.46,85.53
32,Control ,-24.37,-19.32,36.38,88.47
33,Control ,-25.62,-20.29,37.31,91.41
34,Control ,-26.86,-21.27,38.23,94.36
35,Control ,-28.11,-22.25,39.16,97.30
36,Control ,-29.36,-23.22,40.09,100.24
37,Control ,-30.61,-24.20,41.01,103.19
38,Control ,-31.86,-25.18,41.94,106.13
39,Control ,-33.11,-26.16,42.86,109.07
40,Control ,-34.36,-27.13,43.79,112.01
41,Control ,-35.60,-28.11,44.71,114.96
42,Control ,-36.85,-29.09,45.64,117.90
43,Control ,-38.10,-30.06,46.57,120.84
44,Control ,-39.35,-31.04,47.49,123.79
45,Control ,-40.60,-32.02,48.42,126.73
46,Control ,-41.85,-33.00,49.34,129.67
47,Control ,-43.10,-33.97,50.27,132.61
48,Control ,-44.34,-34.95,51.19,135.56
49,Control ,-45.59,-35.93,52.12,138.50
50,Control ,-46.84,-36.90,53.05,141.44
1,Baseline ,-48.09,-37.88,53.97,144.39
2,Baseline ,-49.34,-38.86,54.90,147.33
3,Baseline ,-50.59,-39.84,55.82,150.27
4,Baseline ,-51.84,-40.81,56.75,153.21
5,Baseline ,-53.08,-41.79,57.67,156.16
6,Baseline ,-54.33,-42.77,58.60,159.10
7,Baseline ,-55.58,-43.74,59.53,162.04
8,Baseline ,-56.83,-44.72,60.45,164.99
9,Baseline ,-58.08,-45.70,61.38,167.93
10,Baseline ,-59.33,-46.68,62.30,170.87
11,Baseline ,-60.58,-47.65,63.23,173.81
12,Baseline ,-61.82,-48.63,64.15,176.76
13,Baseline ,-63.07,-49.61,65.08,179.70
14,Baseline ,-64.32,-50.58,66.01,182.64
15,Baseline ,-65.57,-51.56,66.93,185.59
16,Baseline ,-66.82,-52.54,67.86,188.53
17,Baseline ,-68.07,-53.52,68.78,191.47
18,Baseline ,-69.32,-54.49,69.71,194.41
19,Baseline ,-70.56,-55.47,70.63,197.36
20,Baseline ,-71.81,-56.45,71.56,200.30
21,Baseline ,-73.06,-57.42,72.49,203.24
22,Baseline ,-74.31,-58.40,73.41,206.19
23,Baseline ,-75.56,-59.38,74.34,209.13
24,Baseline ,-76.81,-60.36,75.26,212.07
25,Baseline ,-78.06,-61.33,76.19,215.01
26,Baseline ,-79.30,-62.31,77.11,217.96
27,Baseline ,-80.55,-63.29,78.04,220.90
28,Baseline ,-81.80,-64.26,78.97,223.84
29,Baseline ,-83.05,-65.24,79.89,226.79
30,Baseline ,-84.30,-66.22,80.82,229.73
31,Baseline ,-85.55,-67.20,81.74,232.67
32,Baseline ,-86.80,-68.17,82.67,235.61
33,Baseline ,-88.04,-69.15,83.59,238.56
34,Baseline ,-89.29,-70.13,84.52,241.50
35,Baseline ,-90.54,-71.10,85.45,244.44
36,Baseline ,-91.79,-72.08,86.37,247.39
37,Baseline ,-93.04,-73.06,87.30,250.33
38,Baseline ,-94.29,-74.04,88.22,253.27
39,Baseline ,-95.54,-75.01,89.15,256.21
40,Baseline ,-96.78,-75.99,90.07,259.16
41,Baseline ,-98.03,-76.97,91.00,262.10
42,Baseline ,-99.28,-77.94,91.93,265.04
43,Baseline ,-100.53,-78.92,92.85,267.99
44,Baseline ,-101.78,-79.90,93.78,270.93
45,Baseline ,-103.03,-80.88,94.70,273.87
46,Baseline ,-104.28,-81.85,95.63,276.81
47,Baseline ,-105.52,-82.83,96.55,279.76
48,Baseline ,-106.77,-83.81,97.48,282.70
49,Baseline ,-108.02,-84.78,98.41,285.64
50,Baseline ,-109.27,-85.76,99.33,288.59
1,post,-110.52,-86.74,100.26,291.53
2,post,-111.77,-87.72,101.18,294.47
3,post,-113.02,-88.69,102.11,297.41
4,post,-114.26,-89.67,103.03,300.36
5,post,-115.51,-90.65,103.96,303.30
6,post,-116.76,-91.62,104.89,306.24
7,post,-118.01,-92.60,105.81,309.19
8,post,-119.26,-93.58,106.74,312.13
9,post,-120.51,-94.56,107.66,315.07
10,post,-121.76,-95.53,108.59,318.01
11,post,-123.00,-96.51,109.51,320.96
12,post,-124.25,-97.49,110.44,323.90
13,post,-125.50,-98.46,111.37,326.84
14,post,-126.75,-99.44,112.29,329.79
15,post,-128.00,-100.42,113.22,332.73
16,post,-129.25,-101.40,114.14,335.67
17,post,-130.50,-102.37,115.07,338.61
18,post,-131.74,-103.35,115.99,341.56
19,post,-132.99,-104.33,116.92,344.50
20,post,-134.24,-105.30,117.85,347.44
21,post,-135.49,-106.28,118.77,350.39
22,post,-136.74,-107.26,119.70,353.33
23,post,-137.99,-108.24,120.62,356.27
24,post,-139.24,-109.21,121.55,359.21
25,post,-140.48,-110.19,122.47,362.16
26,post,-141.73,-111.17,123.40,365.10
27,post,-142.98,-112.14,124.33,368.04
28,post,-144.23,-113.12,125.25,370.99
29,post,-145.48,-114.10,126.18,373.93
30,post,-146.73,-115.08,127.10,376.87
31,post,-147.98,-116.05,128.03,379.81
32,post,-149.22,-117.03,128.95,382.76
33,post,-150.47,-118.01,129.88,385.70
34,post,-151.72,-118.98,130.81,388.64
35,post,-152.97,-119.96,131.73,391.59
36,post,-154.22,-120.94,132.66,394.53
37,post,-155.47,-121.92,133.58,397.47
38,post,-156.72,-122.89,134.51,400.41
39,post,-157.96,-123.87,135.43,403.36
40,post,-159.21,-124.85,136.36,406.30
41,post,-160.46,-125.82,137.29,409.24
42,post,-161.71,-126.80,138.21,412.19
43,post,-162.96,-127.78,139.14,415.13
44,post,-164.21,-128.76,140.06,418.07
45,post,-165.46,-129.73,140.99,421.01
46,post,-166.70,-130.71,141.91,423.96
47,post,-167.95,-131.69,142.84,426.90
48,post,-169.20,-132.66,143.77,429.84
49,post,-170.45,-133.64,144.69,432.79
50,post,-171.70,-134.62,145.62,435.73
I'm intrested in measuring the effect between the timepoints, which is to substract control from baseline, control from post, baseline from post ( apply this to 4 variables). The final data should consist only of subjects and variables (after being trasformed to effects), either in horizontal or vertical structure.
I appreciate your help
Thank you this worked perfectly with data of dimension 150x4.
My real data has VAR1 to VAR228 and same number of samples. I made little change in this part of the code but didn't work:
data want (drop=_: time);
set have (where=(time='post'))
have (where=(time='Baseline'))
have (where=(time='Control')) ;
by subject;
array vars var1-var228;
array diftwo _diftwo_1 - _diftwo_;
do over vars;
diftwo=dif2(vars);
vars=dif(vars);
end;
length contrast $19;
contrast=catx(' ',time,'-',lag(time));
if contrast in('Control - Baseline','Baseline - post') then output;
if time='Control' and lag2(time)='post' then do;
contrast='Control - post';
do over vars;
vars=diftwo;
end;
output;
end;
run;
I get this error message:
WARNING: The variable '_:'n in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0
observations and 230 variables.
If you want I can accept your answer then I post this question in new post.
Suggestion: Reduce that example to 4 or 5 of each type, something small enough you can calculate what you want or show directly which calculations are involved and desired result.
It may help to describe what you will do with the resulting data as the structure may need to be different for different purposes.
Here is the data for 3 observations:
SUBJECT,SUBJECT,TIME,VAR1,VAR2,VAR3,VAR4
1,1,Control ,17.20,18.50,10.10,-6.20
2,2,Control ,16.30,2.30,8.20,5.00
3,2,Control ,4.50,4.50,6.30,2.00
1,1,Baseline ,-48.09,-37.88,53.97,144.39
2,2,Baseline ,-49.34,-38.86,54.90,147.33
3,3,Baseline ,-50.59,-39.84,55.82,150.27
1,1,post,-110.52,-86.74,100.26,291.53
2,2,post,-111.77,-87.72,101.18,294.47
3,3,post,-113.02,-88.69,102.11,297.41
Samples are paired. Classification using my mutivariate method requires to calculate the difference in observations between timepoints. For example for patient 1 I have 3 effects per VAR1.
I did the substraction for only 3 samples:
SUBJECT | VAR1 | VAR2 | VAR3 | VAR4 |
1 (control-baseline) | 65.29 | 56.38 | -43.87 | -150.59 |
2 (control-baseline) | 65.64 | 41.16 | -46.70 | -142.33 |
3 (control-baseline) | 55.09 | 44.34 | -49.52 | -148.27 |
1 (control-post) | 127.72 | 105.24 | -90.16 | -297.73 |
2 (control-post) | 128.07 | 90.02 | -92.98 | -289.47 |
3 (control-post) | 117.52 | 93.19 | -95.81 | -295.41 |
1 (baseline-post) | 62.43 | 48.86 | -46.29 | -147.14 |
2 (baseline-post) | 62.43 | 48.86 | -46.29 | -147.14 |
3 (baseline-post) | 62.43 | 48.86 | -46.29 | -147.14 |
One way to do this is to
data have;
input SUBJECT TIME :$8. VAR1 VAR2 VAR3 VAR4;
datalines;
1 Control 17.20 18.50 10.10 -6.20
2 Control 16.30 2.30 8.20 5.00
3 Control 4.50 4.50 6.30 2.00
4 Control 8.30 6.30 12.20 7.00
5 Control 8.80 17.30 7.20 8.50
6 Control 12.20 2.30 16.00 11.30
7 Control 6.85 5.11 13.24 14.90
8 Control 5.60 4.14 14.17 17.84
9 Control 4.35 3.16 15.09 20.79
10 Control 3.10 2.18 16.02 23.73
11 Control 1.85 1.20 16.94 26.67
12 Control 0.60 0.23 17.87 29.61
13 Control -0.64 -0.75 18.79 32.56
14 Control -1.89 -1.73 19.72 35.50
15 Control -3.14 -2.70 20.65 38.44
16 Control -4.39 -3.68 21.57 41.39
17 Control -5.64 -4.66 22.50 44.33
18 Control -6.89 -5.64 23.42 47.27
19 Control -8.14 -6.61 24.35 50.21
20 Control -9.38 -7.59 25.27 53.16
21 Control -10.63 -8.57 26.20 56.10
22 Control -11.88 -9.54 27.13 59.04
23 Control -13.13 -10.52 28.05 61.99
24 Control -14.38 -11.50 28.98 64.93
25 Control -15.63 -12.48 29.90 67.87
26 Control -16.88 -13.45 30.83 70.81
27 Control -18.12 -14.43 31.75 73.76
28 Control -19.37 -15.41 32.68 76.70
29 Control -20.62 -16.38 33.61 79.64
30 Control -21.87 -17.36 34.53 82.59
31 Control -23.12 -18.34 35.46 85.53
32 Control -24.37 -19.32 36.38 88.47
33 Control -25.62 -20.29 37.31 91.41
34 Control -26.86 -21.27 38.23 94.36
35 Control -28.11 -22.25 39.16 97.30
36 Control -29.36 -23.22 40.09 100.24
37 Control -30.61 -24.20 41.01 103.19
38 Control -31.86 -25.18 41.94 106.13
39 Control -33.11 -26.16 42.86 109.07
40 Control -34.36 -27.13 43.79 112.01
41 Control -35.60 -28.11 44.71 114.96
42 Control -36.85 -29.09 45.64 117.90
43 Control -38.10 -30.06 46.57 120.84
44 Control -39.35 -31.04 47.49 123.79
45 Control -40.60 -32.02 48.42 126.73
46 Control -41.85 -33.00 49.34 129.67
47 Control -43.10 -33.97 50.27 132.61
48 Control -44.34 -34.95 51.19 135.56
49 Control -45.59 -35.93 52.12 138.50
50 Control -46.84 -36.90 53.05 141.44
1 Baseline -48.09 -37.88 53.97 144.39
2 Baseline -49.34 -38.86 54.90 147.33
3 Baseline -50.59 -39.84 55.82 150.27
4 Baseline -51.84 -40.81 56.75 153.21
5 Baseline -53.08 -41.79 57.67 156.16
6 Baseline -54.33 -42.77 58.60 159.10
7 Baseline -55.58 -43.74 59.53 162.04
8 Baseline -56.83 -44.72 60.45 164.99
9 Baseline -58.08 -45.70 61.38 167.93
10 Baseline -59.33 -46.68 62.30 170.87
11 Baseline -60.58 -47.65 63.23 173.81
12 Baseline -61.82 -48.63 64.15 176.76
13 Baseline -63.07 -49.61 65.08 179.70
14 Baseline -64.32 -50.58 66.01 182.64
15 Baseline -65.57 -51.56 66.93 185.59
16 Baseline -66.82 -52.54 67.86 188.53
17 Baseline -68.07 -53.52 68.78 191.47
18 Baseline -69.32 -54.49 69.71 194.41
19 Baseline -70.56 -55.47 70.63 197.36
20 Baseline -71.81 -56.45 71.56 200.30
21 Baseline -73.06 -57.42 72.49 203.24
22 Baseline -74.31 -58.40 73.41 206.19
23 Baseline -75.56 -59.38 74.34 209.13
24 Baseline -76.81 -60.36 75.26 212.07
25 Baseline -78.06 -61.33 76.19 215.01
26 Baseline -79.30 -62.31 77.11 217.96
27 Baseline -80.55 -63.29 78.04 220.90
28 Baseline -81.80 -64.26 78.97 223.84
29 Baseline -83.05 -65.24 79.89 226.79
30 Baseline -84.30 -66.22 80.82 229.73
31 Baseline -85.55 -67.20 81.74 232.67
32 Baseline -86.80 -68.17 82.67 235.61
33 Baseline -88.04 -69.15 83.59 238.56
34 Baseline -89.29 -70.13 84.52 241.50
35 Baseline -90.54 -71.10 85.45 244.44
36 Baseline -91.79 -72.08 86.37 247.39
37 Baseline -93.04 -73.06 87.30 250.33
38 Baseline -94.29 -74.04 88.22 253.27
39 Baseline -95.54 -75.01 89.15 256.21
40 Baseline -96.78 -75.99 90.07 259.16
41 Baseline -98.03 -76.97 91.00 262.10
42 Baseline -99.28 -77.94 91.93 265.04
43 Baseline -100.53 -78.92 92.85 267.99
44 Baseline -101.78 -79.90 93.78 270.93
45 Baseline -103.03 -80.88 94.70 273.87
46 Baseline -104.28 -81.85 95.63 276.81
47 Baseline -105.52 -82.83 96.55 279.76
48 Baseline -106.77 -83.81 97.48 282.70
49 Baseline -108.02 -84.78 98.41 285.64
50 Baseline -109.27 -85.76 99.33 288.59
1 post -110.52 -86.74 100.26 291.53
2 post -111.77 -87.72 101.18 294.47
3 post -113.02 -88.69 102.11 297.41
4 post -114.26 -89.67 103.03 300.36
5 post -115.51 -90.65 103.96 303.30
6 post -116.76 -91.62 104.89 306.24
7 post -118.01 -92.60 105.81 309.19
8 post -119.26 -93.58 106.74 312.13
9 post -120.51 -94.56 107.66 315.07
10 post -121.76 -95.53 108.59 318.01
11 post -123.00 -96.51 109.51 320.96
12 post -124.25 -97.49 110.44 323.90
13 post -125.50 -98.46 111.37 326.84
14 post -126.75 -99.44 112.29 329.79
15 post -128.00 -100.42 113.22 332.73
16 post -129.25 -101.40 114.14 335.67
17 post -130.50 -102.37 115.07 338.61
18 post -131.74 -103.35 115.99 341.56
19 post -132.99 -104.33 116.92 344.50
20 post -134.24 -105.30 117.85 347.44
21 post -135.49 -106.28 118.77 350.39
22 post -136.74 -107.26 119.70 353.33
23 post -137.99 -108.24 120.62 356.27
24 post -139.24 -109.21 121.55 359.21
25 post -140.48 -110.19 122.47 362.16
26 post -141.73 -111.17 123.40 365.10
27 post -142.98 -112.14 124.33 368.04
28 post -144.23 -113.12 125.25 370.99
29 post -145.48 -114.10 126.18 373.93
30 post -146.73 -115.08 127.10 376.87
31 post -147.98 -116.05 128.03 379.81
32 post -149.22 -117.03 128.95 382.76
33 post -150.47 -118.01 129.88 385.70
34 post -151.72 -118.98 130.81 388.64
35 post -152.97 -119.96 131.73 391.59
36 post -154.22 -120.94 132.66 394.53
37 post -155.47 -121.92 133.58 397.47
38 post -156.72 -122.89 134.51 400.41
39 post -157.96 -123.87 135.43 403.36
40 post -159.21 -124.85 136.36 406.30
41 post -160.46 -125.82 137.29 409.24
42 post -161.71 -126.80 138.21 412.19
43 post -162.96 -127.78 139.14 415.13
44 post -164.21 -128.76 140.06 418.07
45 post -165.46 -129.73 140.99 421.01
46 post -166.70 -130.71 141.91 423.96
47 post -167.95 -131.69 142.84 426.90
48 post -169.20 -132.66 143.77 429.84
49 post -170.45 -133.64 144.69 432.79
50 post -171.70 -134.62 145.62 435.73
run;
data want (drop=_: time);
set have (where=(time='post'))
have (where=(time='Baseline'))
have (where=(time='Control')) ;
by subject;
array vars var1-var4;
array diftwo _diftwo_1 - _diftwo_4;
do over vars;
diftwo=dif2(vars);
vars=dif(vars);
end;
length contrast $19;
contrast=catx(' ',time,'-',lag(time));
if contrast in('Control - Baseline','Baseline - post') then output;
if time='Control' and lag2(time)='post' then do;
contrast='Control - post';
do over vars;
vars=diftwo;
end;
output;
end;
run;
Of course, this does not produce observations in the order you specify (it will be grouped by contrast within subject_id), but the values will be what you want, and you could sort the resulting file.
Crucially, the code above depends on each subject having exactly three time values. A few missing time values could result in say, contrasting Baseline for one subject against post for another, etc.
Now, to directly produce values in the order you specify, you can use this code:
data want (drop=time);
array var var1-var4;
do contrast='Control - Baseline','Control - post','Baseline - post';
do until (dif(e1) or dif(e2) or dif(e3));
if contrast='Control - Baseline' then do;
set have (where=(time='Baseline')) have (where=(time='Control')) end=e1; by subject;
end; else
if contrast='Control - post' then do;
set have (where=(time='post')) have (where=(time='Control')) end=e2; by subject;
end; else
if contrast='Baseline - post' then do;
set have (where=(time='post')) have (where=(time='Baseline')) end=e3; by subject;
end;
do over var;
var=dif(var);
end;
if last.subject then output;
end;
end;
run;
This program first reads all the Baselines followed by the corresponding Control. (that's the BY statement). So each subject id has two observations, and the dif function for the second obs of the subject (i.e. when last.subject=1) produces the Control vs Baseline contrast.
Then the program does the same by reading all the posts followed by corresponding Controls.
And finaly the same for all the posts followed by corresponding Baselines.
Now this code is more easily modified to accomodate missing time values. Just change:
if last.subject then output;
to
if first.subject=0 and last.subject=1 then output;
Some notes:
The "do until (dif(e1) or dif(e2) or dif(e3);" is what tells the major loop to shift from "Control - Baseline" to "Control - post" to "Baseline - post". The e1, e2, and e3 variables are merely end of data dummies for each of the three SET statements.
Thank you this worked perfectly with data of dimension 150x4.
My real data has VAR1 to VAR228 and same number of samples. I made little change in this part of the code but didn't work:
data want (drop=_: time);
set have (where=(time='post'))
have (where=(time='Baseline'))
have (where=(time='Control')) ;
by subject;
array vars var1-var228;
array diftwo _diftwo_1 - _diftwo_;
do over vars;
diftwo=dif2(vars);
vars=dif(vars);
end;
length contrast $19;
contrast=catx(' ',time,'-',lag(time));
if contrast in('Control - Baseline','Baseline - post') then output;
if time='Control' and lag2(time)='post' then do;
contrast='Control - post';
do over vars;
vars=diftwo;
end;
output;
end;
run;
I get this error message:
WARNING: The variable '_:'n in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0
observations and 230 variables.
If you want I can accept your answer then I post this question in new post.
Your response worked very well.
I mistakenly accepted my reply. Please tell me how can I fix this mistake so the right answer is credited to you.
I accepted the answer provided by "mkeintz".
Answer was clear, straighforward and solves the questions from the very begining, and applies to any dimension of data that has identical structure as mine.
It was a simple and irrelevant mistake from my part when applying the codes on the original size and names of variables.
So the accepted answer is as initially provided by "mkeintz":
data want (drop=_: time);
set have (where=(time='post'))
have (where=(time='Baseline'))
have (where=(time='Control')) ;
by subject;
array vars var1-var4;
array diftwo _diftwo_1 - _diftwo_4;
do over vars;
diftwo=dif2(vars);
vars=dif(vars);
end;
length contrast $19;
contrast=catx(' ',time,'-',lag(time));
if contrast in('Control - Baseline','Baseline - post') then output;
if time='Control' and lag2(time)='post' then do;
contrast='Control - post';
do over vars;
vars=diftwo;
end;
output;
end;
run;
data want (drop=time);
array var var1-var4;
do contrast='Control - Baseline','Control - post','Baseline - post';
do until (dif(e1) or dif(e2) or dif(e3));
if contrast='Control - Baseline' then do;
set have (where=(time='Baseline')) have (where=(time='Control')) end=e1; by subject;
end; else
if contrast='Control - post' then do;
set have (where=(time='post')) have (where=(time='Control')) end=e2; by subject;
end; else
if contrast='Baseline - post' then do;
set have (where=(time='post')) have (where=(time='Baseline')) end=e3; by subject;
end;
do over var;
var=dif(var);
end;
if last.subject then output;
end;
end;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.