Ʈ  |  Contact Us
 
Ȩ > SAS Tech & Tip > SAS Programming
Practice 4. First, Last, End Options 2010.01.12
MYSAS 8515 0
http://www.mysas.co.kr/SAS_tiptech/a_question.asp?b_no=963&gotopage=34&con=subject&keyword=&cmd=content&bd_no=05&gubun=

 
 

Practice4. First, Last, End Options

 

  Intro

 

 
Practice 2~3 ó ȿ Data-set о ð ظ ϼ̰?


10 ڸ Ͻø ϴ.


̹ Practice
ϴ ؼ ϵ ϰڽϴ.


!! ׷ ϴ~~


 

 

  Pracitce. Will Data steps require BY or END= variables?

 


 

   1.

FIRST, LAST, END ɼ Ȱ ؼ ˾ƺڽϴ.

Ϲ FIRST, LAST Ű END ɼ ǹ ̴ ͵ ߿ ϳԴϴ

BY (BY ǵ ݵ ) Grouping ó(FIRST) (LAST) մϴ.

END ɼ ͼ ̼ մϴ.

ڼ ؼ ϰڽϴ.
 

   2.

: BY հ BY Ǽ ϴ α׷

Data subtotal;

**Syntax : end=(Ǻ) : ͼ
̼ 1 õ˴ϴ

 

**Syntax : first.(BY) : BY
  Grouping ó 1
 

** Syntax : last.(BY): BY
  Grouping 1

** ͼ ̼
   1  

      set country end=E;
      
by state;
      
where amount <
10;
 

       if first.state then total = 0;
      
total + amount;

       if last.state;
      
n+
1;

       if E then
       put
'THERE WERE  ' N  'STATES'

run;

 

** FIRST, LAST, END ǥ .
       FIRST LAST E 0 or 1 õǴ ǥ ߽ϴ.

STATE

AMOUNT

FIRST.

LAST.

E

CA

20

1
(CA ù ° Obs)

0

0

CA

5

0
 

0

0

CA

15

0

1
(CA Obs)

0

NY

30

1
(NY ù ° Obs)

0

0

NY

3

0
 

0

0

NY

12

0

1
(NY Obs)

1
(ü Obs)

 

 

 

  Exercise

 

 

Q. ǥ õ ͸ state ؼ ͸ ϼ.
    (ݵ Step ϼ.)

 * ÿ ˴ϴ.

 

 

  3ȸ Exercise 

 


proc means data=sashelp.class(where=(sex = 'M'));

           var weight;

run;

 

 

 

 
ڷ ۿ SAS KOREA. , ܹ մϴ

 

 
 
޴ ȣ
޴ ȣ
 
 Practice 5. ڿ Լ
 Practice 3. ȿ Data-Step (2)