-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorld.sas
60 lines (51 loc) · 1.52 KB
/
HelloWorld.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
/********** PRINT HELLO WORLD */
/********** Create Database db1 with String 'Hello World' */
data db1;
********** Format Variable String as character with lenght 11;
format STRING $11.;
STRING="Hello World";
********** Output in SAS log;
put STRING;
********** Output in db1;
output;
run;
title1 "Hello World";
proc print data=db1 noobs;
run;
/********** MACRO HELLO WORLD */
%macro Hello(MYWORD);
/********** Create Database db1 with String 'Hello World' */
data db1;
/********** Format Variable String as character with length 40 */
format STRING $40.;
STRING=&MYWORD;
/********** Output in SAS log with %put */
%put &MYWORD;
/********** Output in db1 */
output;
run;
title1 "Hello World";
proc print data=db1 noobs;
run;
%mend Hello;
%Hello("Hello World (generated with SAS Macro)");
/********** MACRO HELLO WORLD WITH LOOP*/
* Macro for printing Hello World n-times (and Output in SAS log);
%macro MyLoop(NumLoop=, Output=Y);
/********** Declare iterator I as local */
%local I;
/********** Upcase Output */
%let Output=%upcase(&Output);
/********** If Parameter Output is Y = Yes: */
%if &Output=Y %then %do;
/********** Loop */
%do I=1 %to &NumLoop;
%put "Hello World &I"; /********** Output in SAS Log */
%end;
%end;
/********** If Parameter Output is not Y */
%else %do;
%put "Output is not Y"; /********** Output in SAS Log */
%end;
%mend MyLoop;
%MyLoop(NumLoop=8, Output=y);