-
Notifications
You must be signed in to change notification settings - Fork 56
/
PrintSample.sas
39 lines (30 loc) · 975 Bytes
/
PrintSample.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
/* Selection options are FIRST (first rows) or RANDOM (random sample) */
%let selection=FIRST;
/* GET TOTAL ROW COUNT FROM TABLE */
proc sql noprint;
select count(*) format=comma15. into :N from sashelp.homeequity;
quit;
/* SELECT FIRST 20 ROWS */
%if &selection=FIRST %then %do;
title1 color="#545B66" "Sample from SASHELP.HOMEEQUITY";
title2 height=3 "First 20 of &N Rows";
data sample;
set sashelp.homeequity(obs=20 keep=Bad Loan MortDue Value);
run;
%end;
/* SELECT RANDOM SAMPLE OF 20 ROWS */
%else %do;
title1 color="#545B66" "Sample from SASHELP.HOMEEQUITY";
title2 height=3 "Random Sample 20 of &N Rows";
proc surveyselect data=sashelp.homeequity(keep=Bad Loan MortDue Value)
method=srs n=20
out=sample noprint;
run;
%end;
/* PRINT SAMPLE */
footnote height=3 "Created %sysfunc(today(),nldatew.) at %sysfunc(time(), nltime.)";
proc print data=sample noobs;
run;
title;
footnote;
/* END */