-
Notifications
You must be signed in to change notification settings - Fork 0
/
week12_1(macro_functions).sas
86 lines (62 loc) · 1.87 KB
/
week12_1(macro_functions).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
data orders;
set orion.Order_fact;
where year(Order_Date)=2007;
Lag=Delivery_Date - Order_Date;
run;
proc means data=orders maxdec=2 min max mean;
class Order_Type;
var Lag;
title "Report based on ORDERS data";
run;
%put sysdate9=&sysdate9;
%put year=%substr(sysdate9, 6);
data orders;
set orion.Order_fact;
where year(Order_Date)=%substr(&sysdate9,6);
Lag=Delivery_Date - Order_Date;
run;
proc means data=orders maxdec=2 min max mean;
class Order_Type;
var Lag;
title "Report based on ORDERS data";
run;
/*m102d06- (%EVAL )*/
options symbolgen;
%let thisyr=%substr(&sysdate9,6);
%let lastyr=%eval(&thisyr-1);
proc means data=orion.order_fact maxdec=2 min max mean;
class order_type;
var total_Retail_price;
where year(order_date) between &lastyr and &thisyr;
title1 "Orders for &lastyr and &thisyr";
title2 "(as of &sysdate9)";
run;
title;
/*m102d07- (%SYSFUNC )
- array processing(dim, hbound, lbound)
- variable information(vname, vlabel, missing)
- macro interface(resolve, symget)
- data conversion (input/inputn/inputc, put/putc/putn)
- other functions(iorcmsg, lag, dif)
*/
title1 "%sysfunc(today(), weekdate.)";
title2 "%sysfunc(time(), timeAMPM8.)";
proc print data=sashelp.class;
run;
title;
/*quiz
- what is the potential problem with the value of statement??
- 이 코드에서 내가 사실상 의도한 바는 title "Payroll Report" ; 즉 ';'도 포함시키는 것이었어
solution!! : (%STR)
- (+, -, *, /, <, > , = , ; , ', " , not , blank )와 같은 special token의 의미를 없앤다*/
%let statement=title "Payroll Report";
%put &statement;
%let statement = %str(title "Payroll Report" ;);
%put &statement;
/*m102d08*/
%let statement = title "S&P 500" ;
%put &statement;
%let statement = %str(title "S&P 500" ;);
%put &statement;
%let statement = %nrstr(title "S&P 500" ;);
%put &statement;