-
Notifications
You must be signed in to change notification settings - Fork 0
/
getting-started-practice.sas
162 lines (122 loc) · 1.98 KB
/
getting-started-practice.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* University: Universidad de Valladolid
* Degree: Grado en Estadística
* Subject: Regresión y ANOVA
* Year: 2017/18
* Author: Sergio García Prado (garciparedes.me)
* Name: Getting Started Practice
*
*/
/*
* Exercise 1
*/
DATA poblacion;
FORMAT provincia $12.;
INPUT provincia $ poblacion;
CARDS;
Avila 168638
Burgos 365972
Leon 497387
Palencia 173281
Salamanca 351326
Segovia 159322
Soria 95593
;
RUN;
PROC PRINT DATA=poblacion;
RUN;
/*
* Exercise 2
*/
DATA poblasup;
FORMAT provincia $12.;
MERGE poblacion;
INPUT provincia $ superficie;
CARDS;
Avila 8048
Burgos 14269
Leon 15468
Palencia 8029
Salamanca 12336
Segovia 6949
Soria 10287
;
RUN;
PROC PRINT data=poblasup;
RUN;
/*
* Exercise 3
*/
DATA completo;
FORMAT provincia $12.;
INPUT provincia $ poblacion superficie;
CARDS;
Valladolid 521661 8202
Zamora 197237 10559
;
RUN;
PROC APPEND BASE=completo DATA=poblasup;
RUN;
/*
PROC EXPORT data=completo outfile="/folders/myfolders/completo.txt";
RUN;
*/
PROC PRINT DATA=completo;
RUN;
/*
* Exercise 4
*/
DATA completo;
SET completo;
densidad = poblacion / superficie;
RUN;
PROC PRINT DATA=completo;
RUN;
/*
* Exercise 5
*/
PROC SORT DATA=completo;
BY DESCENDING densidad;
RUN;
PROC PRINT DATA=completo;
RUN;
/*
* Exercise 6
*/
DATA clasificado;
SET completo;
FORMAT tamano $12.;
IF superficie <= 10000 THEN tamano = 'pequeno';
ELSE tamano = 'grande';
RUN;
PROC PRINT DATA=clasificado;
RUN;
/*
* Exercise 7
*/
DATA maspobladas;
SET clasificado (WHERE=(poblacion >= 300000));
RUN;
PROC PRINT DATA=maspobladas;
RUN;
/*
* Exercise 8
*/
PROC UNIVARIATE DATA=clasificado;
VAR poblacion superficie;
RUN;
PROC UNIVARIATE DATA=clasificado;
CLASS tamano;
VAR poblacion superficie;
RUN;
/*
* Exercise 9
*/
PROC SGPLOT DATA=clasificado;
reg x=poblacion y=superficie;
RUN;
PROC CORR DATA=clasificado outp=cp_poblacion_superficie;
VAR poblacion superficie;
RUN;
PROC PRINT DATA=cp_poblacion_superficie;
RUN;