forked from anupamaprv/SAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2var-plot.sas
91 lines (71 loc) · 2.83 KB
/
2var-plot.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Author - Anupama Rajaram
Function - Calculate frequency distribution for research questions
Importing data from a file called "anu_ool_pds-w3.csv
this file has 290 rows. Values stored in object call "temp_chk"
*/
data temp_chk;
infile " /home/sunyblogger0/sasuser.v94/anu_ool_pds-wA.csv"
DELIMITER=',' ;
Input CASEID W1_CASEID W2_CASEID2 W1_F3 W1_F4_B W1_F4_D W1_F5_A W1_F6 PPAGECAT
PPGENDER PPMARIT;
/* Giving labels to variable names for better understanding */
LABEL CASEID = "Case Number"
W1_F3 = "Belief in achieving American Dream"
W1_F4_B = "Achieving financially secure retirement"
W1_F4_D = "Achieving wealth"
W1_F5_A = "Owning a home"
W1_F6 = "How close to achieve the American Dream"
PPAGECAT = "Age"
PPGENDER = "Gender"
PPMARIT = "Mstat"
MARG = "Marital status";
/* Coding for missing values as part of Data Management */
IF W1_F3 = -1 THEN W1_F3 = .;
IF W1_F4_B = -1 THEN W1_F4_B = .;
if W1_F4_D = -1 then W1_F4_D =.;
IF W1_F5_A = -1 THEN W1_F5_A =.;
IF W1_F6 = -1 THEN W1_F6 =.;
/* changing marital status categories */
IF (PPMARIT = 1 OR PPMARIT = 6) THEN MARG =1 ;
ELSE IF (PPMARIT = 2 OR PPMARIT = 3 OR PPMARIT =4) THEN MARG = 2;
ELSE IF PPMARIT = 5 THEN MARG = 5;
/* Only considering participants in age range 25-34 */
IF PPAGECAT=2;
/* CREATING A COMPOUND VARIABLE - wealth_conf */
WEALTH_CONF = SUM (OF W1_F4_B W1_F4_D W1_F5_A);
IF W1_F4_B =. OR W1_F4_D = . OR W1_F5_A =. THEN WEALTH_CONF = .;
/* The command above ensures that if values for either
of the THREE variables are missing, then the wealth_conf
is also coded as "." or missing. */
/*LABEL WEALTH_CONF = "Confidence to achieve wealth and secure retirement";
*/
/* PRINTING THE INDIVIDUAL VARIABLES TO VIEW WEALTH CONFIDENCE
this part of the code is currently commented out */
/* PROC PRINT; VARIABLES W1_F4_B W1_F4_D WEALTH_CONF ; */
/* Computing frequency distribution for 5 variables */
PROC FREQ DATA = temp_chk;
TABLES WEALTH_CONF MARG;
/* creating bar graph chart for varibale wealth_conf
TITLE 'Financial secure retirement (count)';
PROC GCHART; VBAR W1_F4_B/discrete ; */
TITLE 'Wealth Confidence in %';
PROC GCHART; VBAR WEALTH_CONF/DISCRETE TYPE= percent;
run;
/* graph showing wealth confidence by marital status */
title1 ls=1.5 "wealth confidence by marital status";
pattern1 v=solid color= big;
pattern2 v=solid color = antiquewhite;
pattern3 v=solid color = darkorange;
proc gchart data=temp_chk;
vbar MARG/discrete type= sum sumvar=WEALTH_CONF
group=WEALTH_CONF subgroup=MARG freq;
run;
/* graph showing wealth confidence by marital status */
title1 ls=1.5 "wealth confidence by marital status";
pattern1 v=solid color= big;
pattern2 v=solid color = antiquewhite;
pattern3 v=solid color = darkorange;
proc gchart data=temp_chk;
vbar MARG/discrete type= sum sumvar=W1_F4_B
group=W1_F4_B subgroup=MARG freq;
run;