BookmarkSubscribeRSS Feed

[기초부터 배우는 SAS Programing] 6. DATA step 실행과정

Started ‎06-15-2020 by
Modified ‎06-15-2020 by
Views 430

기초부터(8).png

 

 

 

DATA step 실행과정

 

Infile 할 때 SAS 내부에서 어떻게 읽어들이는지 DATA step실행과정에 대해 알아보겠습니다.

AnyConv.com__6-1(1).png

위와 같은 SAS data set이 만들어지는 과정을 예로 들어보겠습니다.

DATA step 실행과정은 크게 Compiling과정과 Executing과정으로 나누어집니다.

 

1. Comliling

 ① Input Buffer  :  raw data 공간 확보

 

data aa.student;
infile 'F:\ex\student.txt';  <-
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run;

 

 Input Buffer
                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

② PDV  :  Input Buffer를 통해 만든 SAS data의 공간 확보
 
data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-3 <- Age 5-Sex $ Weight 10-13 Height 15-19;
run;

  PDV 

 

       ID
      $ 3
 

 

 

 

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-6 <- Sex $ Weight 10-13 Height 15-19;
run;

 

   PDV  ( ※ 숫자변수는 무조건 8바이트로 생성)

 

ID

$ 3

Age

8

 

 

 

    .

    .

    .

  PDV

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 

 

 

 

 

 

③ SAS data set의 description 생성 :  PDV안의 정보를 output으로 내보냄

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run;  <-

 

 Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  PDV

 

ID

Age

Sex

Weight

Height

 

 

 

 

 

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 

2. Executing

   raw data

 

100 18 F 49.0 158.5

101 17 M 65.8 172.5

102 17 F 54.5 167.3

103 19 F 51.3 160.9

104 18 M 78.0 181.1

105 18 M 78.6 177.7

 

 

 

data aa.student;
infile 'F:\ex\student.txt';
input <- ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 
  PDV

 

ID

Age

Sex

Weight

Height

 

 

 

 

 

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-3 <- Age 5-Sex $ Weight 10-13 Height 15-19;
run;

 

  Input Buffer  

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 
  PDV

 

ID

Age

Sex

Weight

Height

      100

 

 

 

 

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-6 <- Sex $ Weight 10-13 Height 15-19;
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 

  PDV

 

ID

Age

Sex

Weight

Height

     100

       18 

 

 

 

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ 8 <- Weight 10-13 Height 15-19;
run;

 

  Input Buffer 

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 

   PDV

 

ID

Age

Sex

Weight

Height

      100

        18 

        F

 

 

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 ⑤ 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 <- Height 15-19;
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 

   PDV

 

ID

Age

Sex

Weight

Height

      100

         18

        F 

       49.0 

 

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

⑥ 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19 <- ;
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 

  PDV

 

ID

Age

Sex

Weight

Height

      100

         18

        F 

       49.0 

      158.5

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

 

 

 ⑦ PDV안의 내용이 output으로 => Automatic output  

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run; <- output으로 출력, 다시 올라가서 return. (끌날 때까지)

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

 

  PDV

 

ID

Age

Sex

Weight

Height

        100

           18

          F 

         49.0 

        158.5

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

100

18

F

49.0

158.5

 

 

 ⑧

 

data aa.student; <-
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

0

 

1

8

 

F

 

4

9

.

0

 

1

5

8

.

5

  PDV  <- PDV 초기화

 

ID

Age

Sex

Weight

Height

       

          

         

       

      

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

100

18

F

49.0

158.5

 

 

 ⑨

data aa.student;
infile 'F:\ex\student.txt';
input <- ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9

1

0

1

 

1

7

 

M

 

6

5

.

8

 

1

7

2

.

5

  PDV 

 

ID

Age

Sex

Weight

Height

       

          

         

       

      

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

100

18

F

49.0

158.5

 

 

⑩  

 

data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19; <-
run;

 

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9
1
0
1
 
1
7
 
M
 
6
5
.
8
 
1
7
2
.
5

  PDV 

 

ID
Age
Sex
Weight
Height
101
17          
M         
65.8       
172.5      

 

  description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

100

18

F

49.0

158.5

 

 

 

 ⑪
data aa.student;
infile 'F:\ex\student.txt';
input ID $ 1-Age 5-Sex $ Weight 10-13 Height 15-19;
run; <-

  Input Buffer

                                                                             1                                                                        1 
  1       2      3      4       5       6       7       8      9        0       1      2        3      4       5      6       7       8      9
1
0
1
 
1
7
 
M
 
6
5
.
8
 
1
7
2
.
5

 PDV 

ID
Age
Sex
Weight
Height
101
17          
M         
65.8       
172.5      

 description portion

 

ID

$3

Age

8

Sex

$1

Weight

8

Height

8

100

18

F

49.0

158.5

101

17

M

65.8

172.5

 

위 과정을 raw data를 모두 읽을 때까지 반복하고, 다 읽어들인 후 SAS data set이 생성됩니다.

 

 

Version history
Last update:
‎06-15-2020 04:46 AM
Updated by:
Contributors

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Article Labels
Article Tags