-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04 SAS Syntax.sas
147 lines (128 loc) · 3.29 KB
/
04 SAS Syntax.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
filename pt '/courses/d649d56dba27fe300/Data Sets/PlatingTransistors.txt';
data Trans;
infile pt;
input Thick @@;
label Thick = 'Plating Thickness (mils)';
run;
title 'Analysis of Plating Thickness';
proc print data=Trans (obs=10) label;
run;
filename emps '/courses/d649d56dba27fe300/Data Sets/newemps.csv';
data NewSalesEmps;
length First_Name $ 12 Last_Name $ 18
Job_Title $ 25;
infile emps dlm=",";
input First_Name $ Last_Name $
Job_Title $ Salary /*numeric*/;
run;
data employees_tmp;
set newsalesemps;
call streaminit(54321);
if rand("uniform") le .05 then job_title="";
if rand("uniform") le .1 then salary=.;
run;
proc print data=employees_tmp;
run;
proc univariate data=work.trans;
histogram thick;
qqplot thick;
run;
data tmp;
x=5;
y=x*2;
z=x**2;
a=sqrt(z);
b="A character variable";
run;
proc print data=tmp;
run;
data tmp;
do i=1 to 5;
x=i;
y=x*2;
z=x**2;
a=sqrt(z);
b="A character variable";
output;
end;
run;
proc print data=tmp;
run;
/*
Source: R 9.2 (AER package)
Written by R using write.foreign
*/
*------------------------------------------------------------|
|Wages of employees of a US bank. |
|Source Online complements to Heij, de Boer, Franses, Kloek, |
|and van Dijk (2004). |
|References |
|Heij, C., de Boer, P.M.C., Franses, P.H., Kloek, T. and |
|van Dijk, H.K. (2004). |
|Econometric Methods with Applications in Business and |
|Economics. Oxford: Oxford University Press. |
|------------------------------------------------------------;
PROC FORMAT;
value job
1 = "custodial"
2 = "admin"
3 = "management"
;
value gender
1 = "male"
2 = "female"
;
value minority
1 = "no"
2 = "yes"
;
run;
FILENAME wages '/courses/d649d56dba27fe300/Data Sets/BankWages.txt';
DATA wages ;
INFILE '/courses/d649d56dba27fe300/Data Sets/BankWages.txt' DLM=',';
INPUT job education gender minority;
FORMAT job job. gender gender. minority minority.;
RUN;
proc print data=wages (obs=25);
run;
FILENAME emps '/courses/d649d56dba27fe300/Data Sets/newemps.csv';
data work.NewSalesEmps;
length First_Name $ 12 Last_Name $ 18
Job_Title $ 25;
infile emps dlm=',';
input First_Name $ Last_Name $
Job_Title $ Salary /*numeric*/;
run;
/*proc print data=NewSalesEmps; run; */
proc means data=NewSalesEmps;
*class Job_Title;
var Salary;
run;
proc freq data=sashelp.heart;
tables sex*status;
run;
Filename emps '/courses/d649d56dba27fe300/Data Sets/newemps.csv';
data work.NewSalesEmps;
length First_Name $ 12 Last_Name $ 18
Job_Title $ 25;
infile emps dlm=",";
input First_Name $ Last_Name $
Job_Title $ Salary /*numeric*/;
bonus=salary*.1;
run;
proc print data=NewSalesEmps(obs=21) noobs;
run;
data NewSalesEmps;
length First_Name $ 12 Last_Name $ 18 Job_Title $ 25;
infile emps dlm=',';
input First_Name $ Last_Name $ Job_Title $ Salary ;
run;
/*missing semicolon*/
proc means data=NewSalesEmps
var Salary;
run;
/*incorrect key word
Notice that average is not blue because the correct keyword is mean*/
proc means data=NewSalesEmps average;
var Salary;
run;