-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_DevPrev.sas
63 lines (52 loc) · 1.44 KB
/
03_DevPrev.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Author: Jan Vallee
Date: 18.03.2020
DEVIATION PREVIOUS
Description: Calculates the hotizontal distances between the answers. Calculates sum of distances and divides by number of Items-1. Score can range from 0 to 5
*/
*2. Recoding "No answer" from 0 to 6 to include it in the analysis*;
Data DevPrev;
set Data.P_HH;
array item AutonomyPT1-- ODMevaluation11;
do over item;
if item =0 then item =6;
end;
run;
data DevPrev2;
set DevPrev;
array cols{38} AutonomyPT1-- ODMevaluation11; /* creating arrays to simplify code*/
array diffs{37} 8.;
do i=2 to 38; /* no comparison on first */
diffs{i-1}=cols{i}-cols{i-1};
if diffs{i-1} < 0 then diffs{i-1}=diffs{i-1}*(-1);
end;
run;
data DevPrev3;
set DevPrev2;
array diff {*} diffs1 -- diffs37;
sum_allnum= sum (of diff [*]);
run;
data DevPrev4;
set DevPrev3;
DevPrev = round(sum_allnum/37, 0.01);
run;
/*Average of personal score by city*/
proc means data = DevPrev4 MEAN;
var DevPrev;
class CityHousehold;
output out = DevPrev_MW;
run;
proc export data = DevPrev_MW
outfile = "&path_data.\SAS_Export_New\Results.xlsx"
dbms = xlsx
replace;
sheet="DevPrev_MW";
run;
*Identification of people with a very low score -> Danger of straightlining;
proc print data=DevPrev4;
where CityHousehold = 1 AND DevPrev < 0.1;
run;
data test;
set DevPrev4;
where CityHousehold = 8 AND DevPrev < 0.1;
run;