0% found this document useful (0 votes)
2 views2 pages

Code_ Homework 28.sas

The document contains SAS code for a homework assignment involving statistical analyses. It includes data manipulation and t-tests for comparing scores from different programs, as well as paired and unpaired analyses of weight data before and after a diet intervention. The code demonstrates the use of arrays, loops, and statistical procedures in SAS.

Uploaded by

jongmyeong WEE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Code_ Homework 28.sas

The document contains SAS code for a homework assignment involving statistical analyses. It includes data manipulation and t-tests for comparing scores from different programs, as well as paired and unpaired analyses of weight data before and after a diet intervention. The code demonstrates the use of arrays, loops, and statistical procedures in SAS.

Uploaded by

jongmyeong WEE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

4/11/25, 10:04 AM Code: Homework 28.

sas

/* Question 1 */
data reading;
input program $ score1-score14;
array scores{14} score1-score14;
do i = 1 to 14;
score = scores{i};
output;
end;
drop score1-score14 i;
datalines;
Cody 500 450 505 404 555 567 588 577 566 644 511 522 543 578
Smith 355 388 440 600 510 501 502 489 499 489 515 520 520 480
;
run;

proc ttest data=reading;


class program;
var score;
run;

proc npar1way data=reading wilcoxon;


class program;
var score;
exact wilcoxon;
run;

/* Question 2 */
DATA QUES6_4;
DO GROUP = 'A','B','C';
DO I = 1 TO 10;
X = ROUND(RANNOR(135)*10 + 300 + 5*(GROUP EQ 'A') - 7*(GROUP EQ 'C'));
Y = ROUND(RANUNI(135)*100 + X);
OUTPUT;
END;
END;
DROP I;
RUN;

PROC TTEST DATA=QUES6_4;


CLASS GROUP;
VAR X Y;
RUN;

/* Question 3 */
DATA diet;
INFILE '/home/u64124859/cody_chap06_num06-1.dat';
INPUT Status $ weight1-weight12;
ARRAY weight{12} weight1-weight12;

DO i = 1 TO 12;
IF i <= 12 THEN DO;
Status = 'Before';
weight_value = weight{i};
subject_id = i;
OUTPUT;
END;
END;
about:blank 1/2
4/11/25, 10:04 AM Code: Homework 28.sas

DO i = 1 TO 12;
IF i <= 12 THEN DO;
Status = 'After';
weight_value = weight{i};
subject_id = i;
OUTPUT;
END;
END;

DROP weight1-weight12 i;
RUN;

/* Step 2: Paired Data */


DATA diet_paired;
SET diet;
BY subject_id;
IF Status = 'Before' THEN before_weight = weight_value;
IF Status = 'After' THEN after_weight = weight_value;

IF Status = 'After' THEN OUTPUT;


RUN;

PROC TTEST DATA=diet_paired;


CLASS Status;
VAR weight_value;
RUN;

DATA diet_unpaired;
SET diet;
IF Status = 'Before' THEN Group = 'Before';
ELSE IF Status = 'After' THEN Group = 'After';
RUN;

PROC TTEST DATA=diet_unpaired;


CLASS Group;
VAR weight_value;
RUN;

about:blank 2/2

You might also like