-
Notifications
You must be signed in to change notification settings - Fork 0
/
W0.txt
114 lines (102 loc) · 2.73 KB
/
W0.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
DATA WORK.CARS;
SET SASHELP.CARS;
LENGTH CLASS $10.;
IF MSRP>30000 THEN DO;
CLASS="LUXURY";
PRICE="HIGH";
END;
ELSE CLASS="NOT HIGH";
IF UPCASE(ORIGIN)="EUROPE" THEN TAXES=MSRP*0.1;
UNIQUE_CAR=CATX("|",MAKE,MODEL);
PROFIT=MSRP-INVOICE;
FINAL=SUM(PROFIT,TAXES*-1);
RUN;
PROC PRINT DATA=WORK.CARS;
RUN;
------------------------------------------------------------------------------
DATA EUROCARS;
SET SASHELP.CARS;
IF UPCASE(ORIGIN)="EUROPE";
PROFIT=MSRP-INVOICE;
IF PROFIT>5000;
RUN;
PROC PRINT DATA=EUROCARS;
RUN;
------------------------------------------------------------------------------
PROC SORT DATA=E OUT=E_SORT;
BY NO;
RUN;
PROC SORT DATA=AT OUT=AT_SORT;
BY NO;
RUN;
DATA AT_E;
MERGE AT_SORT (IN=A) E_SORT (IN=B);
BY NO;
IF A=1 AND B=1;
RUN;
DATA AT_no_E;
MERGE AT_SORT (IN=A) E_SORT (IN=B);
BY NO;
IF A=1 AND B=0;
RUN;
------------------------------------------------------------------------------
/* format, label, split, PROC format
(help->learning SAS programming) */
DATA WORK.FINANCE;
SET FINANCE.FINANCE;
LABEL SSN = "Social Security Number";
RUN;
PROC PRINT;
RUN;
PROC PRINT DATA=WORK.FINANCE LABEL SPLIT="*";
FORMAT SALARY DOLLAR12.2 NAME $4. DATA DDMMYY10.;
LABEL Name="First *Name";
RUN;
------------------------------------------------------------------------------
DATA WORK.FINANCE;
SET FINANCE.FINANCE;
LABEL SSN = "Social Security Number";
RUN;
PROC PRINT;
RUN;
PROC FORMAT;
VALUE SALARYRANGE 0-<25000="SALARY1"
25000-<30000="SALARY2"
30000-<50000="SALARY3";
RUN;
PROC PRINT DATA=WORK.FINANCE LABEL SPLIT="*";
FORMAT SALARY SALARYRANGE. NAME $4. DATA DDMMYY10.;
LABEL Name="First *Name";
RUN;
------------------------------------------------------------------------------
TITLE "Origin and Drivetrain Freq - one way";
PROC FREQ DATA=SASHELP.CARS;
TABLES ORIGIN DRIVETRAIN;
RUN;
TITLE "Origin and Drivetrain Freq - n way (pivot table)";
PROC FREQ DATA=SASHELP.CARS;
TABLES ORIGIN*DRIVETRAIN;
RUN;
TITLE "Origin and Drivetrain Freq - n way (option list)";
PROC FREQ DATA=SASHELP.CARS;
TABLES ORIGIN*DRIVETRAIN/LIST;
RUN;
TITLE "Origin and Drivetrain Freq - n way (option cross list)";
PROC FREQ DATA=SASHELP.CARS;
TABLES ORIGIN*DRIVETRAIN/CROSSLIST;
RUN;
TITLE "Origin and Drivetrain Freq - n way (option list with output)";
PROC FREQ DATA=SASHELP.CARS;
TABLES ORIGIN*DRIVETRAIN/LIST OUT=FREQ;
RUN;
------------------------------------------------------------------------------
TITLE "PROC MEAN - all numeric vairables";
PROC MEANS DATA=SASHELP.CARS;
RUN;
PROC MEANS DATA=SASHELP.CARS MEAN KURT SKEW;
VAR MSRP;
RUN;
PROC MEANS DATA=SASHELP.CARS MEAN KURT SKEW;
CLASS ORIGIN;
VAR MSRP;
RUN;