-
Notifications
You must be signed in to change notification settings - Fork 1
/
GUI_Program_SAS_SCL.txt
200 lines (157 loc) · 30.1 KB
/
GUI_Program_SAS_SCL.txt
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
INIT:
dcl list makevars;
submit continue;
proc sql noprint;
create view makeqry as
select distinct make
from Vehicles.vehicles
order by make desc;
quit;
endsubmit;
nlevels = 0;
makedata=open('makeqry', 'I');
if (makedata > 0) then do;
makevars = makelist();
rc = lvarlevel(makedata, 'make', nlevels, makevars);
end;
makecbo.items = makevars;
rc = close(makedata);
return;
makecbo:
dcl char makevar;
dcl list modelvars;
dcl list engvars;
dcl list transvars;
dcl list fuelvars;
if makecbo.selectedItem ne ' ' then do;
makevar = makecbo.selectedItem;
* MODEL CBO;
submit continue;
proc sql noprint;
create view modelqry as
select distinct model
from Vehicles.vehicles
where make = '&makevar'
order by model desc;
quit;
endsubmit;
nlevels = 0;
modeldata=open('modelqry', 'I');
if (modeldata > 0) then do;
modelvars = makelist();
rc = lvarlevel(modeldata, 'model', nlevels, modelvars);
end;
modelcbo.items = modelvars;
rc = close(modeldata);
* ENGINE CBO;
submit continue;
proc sql noprint;
create view engqry as
select distinct engId
from Vehicles.vehicles
where make = '&makevar'
order by engId desc;
quit;
endsubmit;
nlevels = 0;
engdata=open('engqry', 'I');
if (engdata > 0) then do;
engvars = makelist();
rc = lvarlevel(engdata, 'engId', nlevels, engvars);
end;
engcbo.items = engvars;
rc = close(engdata);
* TRANSMISSION CBO;
submit continue;
proc sql noprint;
create view transqry as
select distinct trany
from Vehicles.vehicles
where make = '&makevar'
order by trany desc;
quit;
endsubmit;
nlevels = 0;
transdata=open('transqry', 'I');
if (transdata > 0) then do;
transvars = makelist();
rc = lvarlevel(transdata, 'trany', nlevels, transvars);
end;
transcbo.items = transvars;
rc = close(transdata);
* FUEL TYPE CBO;
submit continue;
proc sql noprint;
create view fuelqry as
select distinct fueltype
from Vehicles.vehicles
where make = '&makevar'
order by fueltype desc;
quit;
endsubmit;
nlevels = 0;
fueldata=open('fuelqry', 'I');
if (fueldata > 0) then do;
fuelvars = makelist();
rc = lvarlevel(fueldata, 'fueltype', nlevels, fuelvars);
end;
fuelcbo.items = fuelvars;
rc = close(fueldata);
end;
return;
btnOutput:
dcl char fpath;
dcl char strfilter;
fpath = "C:\Path\To\Output\File.csv";
strfilter = "1 = 1";
if makecbo.selectedItem ne ' ' then do;
strfilter = strfilter || " AND make='"|| makecbo.selectedItem ||"'";
end;
if modelcbo.selectedItem ne ' ' then do;
strfilter = strfilter || " AND model='"|| modelcbo.selectedItem ||"'";
end;
if yearstarttxt.text ne ' ' and yearendtxt.text ne ' ' then do;
strfilter = strfilter || " AND year BETWEEN "|| yearstarttxt.text ||" AND "|| yearendtxt.text;
end;
if engcbo.selectedItem ne ' ' then do;
strfilter = strfilter || " AND engId="|| engcbo.selectedItem;
end;
if transcbo.selectedItem ne ' ' then do;
strfilter = strfilter || " AND trany='"|| transcbo.selectedItem ||"'";
end;
if fuelcbo.selectedItem ne ' ' then do;
strfilter = strfilter || " AND fueltype='"|| fuelcbo.selectedItem ||"'";
end;
submit continue;
proc sql noprint;
create view guireport as
SELECT Vehicles.Make, Vehicles.Model, Vehicles.Year,
Vehicles.EngId, Vehicles.Trany, Vehicles.FuelType,
Avg(Vehicles.barrels08) AS BarrelsAvg, Avg(Vehicles.city08) AS CityMPGAvg,
Avg(Vehicles.comb08) AS CombinedMPGAvg, Avg(Vehicles.highway08) AS HighwayMPGAvg,
Avg(Vehicles.fuelCost08) AS FuelCostAvg
FROM Vehicles.Vehicles
WHERE &strfilter
GROUP BY Vehicles.make, Vehicles.model, Vehicles.Year,
Vehicles.engId, Vehicles.trany, Vehicles.fuelType;
quit;
proc export
data = Work.guireport
outfile = "&fpath"
dbms = csv replace;
run;
endsubmit;
dcl list commandlist;
commandlist=makelist();
commandlist=insertc(commandlist,'Successfully outputted queried data to csv.',1);
dcl char command;
command = messagebox(commandlist,'I','O');
refresh;
return;
term:
rc = dellist(makevars);
rc = dellist(modelvars);
rc = dellist(engvars);
rc = dellist(transvars);
rc = dellist(fuelvars);
return;