-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom sampling
75 lines (53 loc) · 1.8 KB
/
random sampling
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
DM LOG "CLEAR" LOG;
%LET PATH=\\fy14_q4_domestic;
LIBNAME SASDATA "&PATH.\SASDATA";
DATA SASDATA.NON_STD;
SET SASDATA.mall_dom_wi;
IF MAN_SYS= "N";
RUN;
%MACRO RANDOM_SAMPLING(DSN,IN,SAMPLE_NO);
PROC SQL;
CREATE TABLE SASDATA.&IN._JRN_SUM AS SELECT JRN_ENTRY AS JRN_ENTRY,COUNT(*) AS JE_COUNT_NEW,MAN_SYS AS MAN_SYS,SUM(DEBIT_AMT) AS DEBIT_AMT,
SUM(CREDIT_AMT) AS CREDIT_AMT,SUM(AMOUNT) AS AMOUNT
FROM &DSN.
GROUP BY JRN_ENTRY;
QUIT;
DATA SASDATA.&IN._JRN_N_SUM;
SET SASDATA.&IN._JRN_SUM;
RUN;
PROC SORT DATA=SASDATA.&IN._JRN_N_SUM NODUPKEY;
BY _ALL_;
RUN;
DATA WORK.&IN._INV_DET;
SET SASDATA.&IN._JRN_N_SUM;;
***** ASSIGNING A RANDOM NUMBER FOR EACH RECORD *****;
RANNO=RANUNI(0);
RUN;
PROC SORT DATA = WORK.&IN._INV_DET;
BY RANNO;
RUN;
DATA SASDATA.&IN._RANDOM_SAMPLES (DROP=RANNO);
SET WORK.&IN._INV_DET(OBS = &SAMPLE_NO.);
RUN;
%MEND RANDOM_SAMPLING;
%RANDOM_SAMPLING(SASDATA.NON_STD,NON_STD,25);
*********** EXTRACT DETAILS OF ENTRIES SELECTED ************************;
%MACRO EXTRACT(DSN,IN);
PROC SQL;
CREATE TABLE SASDATA.&IN._DETAILS AS SELECT * FROM &DSN.
WHERE JRN_ENTRY IN (SELECT DISTINCT JRN_ENTRY FROM SASDATA.&IN._RANDOM_SAMPLES);
QUIT;
*************** EXPORTING THE ENTRIES SELECTED **************************;
PROC EXPORT DATA= SASDATA.&IN._RANDOM_SAMPLES
OUTFILE= "\\hdcaersnas\aers\CENTRAL\mallinckrodt_mal1030101\FY14_Q4\DOMESITC\OUTPUT\&IN._RANDOM_SAMPLES.TXT"
DBMS=DLM REPLACE;
DELIMITER='7C'x;
RUN;
***************************** EXPORTING THE DETAILS OF ENTRIES SELECTED *************;
PROC EXPORT DATA= SASDATA.&IN._DETAILS
OUTFILE= "\\hdcaersnas\aers\CENTRAL\mallinckrodt_mal1030101\FY14_Q4\DOMESITC\OUTPUT\&IN._DETAILS.TXT"
DBMS=DLM REPLACE;
DELIMITER='7C'x;
RUN;
%MEND;
%EXTRACT(SASDATA.NON_STD,NON_STD);