SAS - PowerPoint PPT Presentation

About This Presentation
Title:

SAS

Description:

Title: SAS Author: panyan Last modified by: qy Created Date: 5/29/2001 3:32:07 AM Document presentation format: Company: JD Other titles – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 39
Provided by: pan144
Category:
Tags: sas | print | proc

less

Transcript and Presenter's Notes

Title: SAS


1
SAS??????
  • ???????

2
??? ???????
  • ????????????????,??,???????????,????????,?????????
    ??
  • IF
  • DO END
  • GOTO
  • RETURN

3
4.1 IF ??
  • ??IF??
  • ???IF??,????THEN???ELSE??(??)?????IF??????????
    ?????SAS?????THEN??????,??????ELSE????????????
  • ???IF??,?THEN??????SAS??????????IF ??????????

4
  • IF-THEN/ELSE??
  • ??
  • IF expression THEN statement
  • ltELSE statementgt
  • ??
  • SAS???????IF?????(expression)??,??????(??),???THE
    N?????????,????ELSE?????,????ELSE??,?????????
  • ??
  • ?THEN???????????,?????????,???DO-END?????????????
    ???
  • IF-THEN/ELSE ?????? ?

5
4.2 GO TO (GOTO)??
  • ??
  • GOTO label
  • ? GO TO label
  • ??
  • GO TO (??GOTO)????SAS??,?????GOTO????????,
    ????????????GO TO??????????????DATA??,????????GO
    TO???????????????
  • label ??GOTO????????

6
4.3 RETURN??
  • ??RETURN
  • RETURN??????????????????,???????????DATA?????,???
    ???????
  • GO TO?????DO-END?????

7
4.4 ??
  • ?????????????????????,??????????????
  • DATA _NULL_
  • I1
  • K PUT I
  • II1
  • IF Ilt10 THEN GOTO K
  • RUN

8
4.4 ??
  • ???????
  • DO ?????? TO ?? BY ??
  • END
  • ??
  • DO?????????,???????????????????,?????
    END???, ??????????????,???????,??????????????????
    ??DO????????????,??????????

9
4.4 ??
  • ??????,??????????????????????????????,????????????
    ???,???????1?????????????????????

10
4.4 ??
DATA _NULL_ DO I1 TO 10 PUT I END RUN
  • PUT????????????,????????????????????
  • ?PUT I

11
4.4 ??
  • ????(????)
  • DO
  • DO
  • END
  • END

12
4.4 ??
  • ????(????)
  • DATA _NULL_
  • DO I1 TO 9
  • DO J1 TO I
  • XIJ
  • PUT _at_(J5) X _at_
  • END
  • PUT
  • END
  • RUN

13
4.4 ??
  • DATA _NULL_
  • DO I1 TO 9
  • DO J1 TO I
  • X IJ
  • PUT J 1. '' I 1. '' X 2. 2 _at_
  • END
  • PUT
  • END
  • RUN

14
4.5 ???????????
  • 4.5.1 DELETE ??
  • ??DELETE
  • DELETE????SAS????????????, ??????????????????,SAS
    ????DATA?????????????

15
4.5.2????IF??
  • ??
  • IF expression
  • ?????IF??,?SAS?????????IF??????????,
    ??????????????????

16
4.5.2????IF??
  • ???????(??????),SAS???????????????DATA
    ???????????????(0???),SAS???????DATA????,?????????
    ??????????
  • ? IF SEXF
  • ???(IF SEXM THEN DELETE
  • ??????????????SEX???F???????

17
4.5.2????IF??
  • DATA A
  • INPUT NAME SEX _at__at_
  • CARDS
  • ZHANG F LI M SUN F WANG F
    LIU M ZHAO M
  • PROC PRINT RUN
  • DATA B
  • SET A
  • IF SEX'F'
  • PROC PRINT
  • RUN

18
??? SAS????
  • ?????????????
  • ????SORT??,?????????
  • ?????SET??,????????
  • ?????MERGE??,????????
  • ??????PUT?FILE?OUTPUT
  • SAS?????????

19
5.1 ????SAS???
  • ???????????????????
  • ???(???)?SAS?????????(??)??SAS??????????????
  • ?????WORK,??????SAS?????,??SAS???????????
  • ?????LIBNAME???????????,????????????? ?
  • ??SAS?,SAS?????????
  • SASUSER???,???LIBNAME???
  • WORK???,??????(?????)?

20
  • ????????????
  • LIBNAME??
  • DATA ??
  • ????????????????????????,????????,??????????????

21
  • 5.1.1 LIBNAME??
  • ??LIBNAME ??? ??
  • ?LIBNAME LC C\EXERCISE
  • ????????,???????????
  • LIBNAME PAN D\PANYAN
  • LIBNAME LA A

22
  • 5.1.2 DATA??
  • ???????
  • ?LIBNAME????SAS????
  • ?DATA???????????(?.??)
  • ?LIBNAME LA A
  • DATA LA.AA
  • LIBNAME PAN D\PANYAN
  • DATA PAN.ABC

23
?????????
  • SAS??????????.SD2,??? ?
  • ????LIBNAME????????????
  • LIBNAME LA A LC C\

24
????????
  • ???????
  • LIBNAME LA A
  • PROC PRINT DATA LA.AA

25
5.2 ????
  • SAS??SORT???????????????
  • SORT??????????
  • PROC SORT ??
  • BY ??

26
5.2 ????
  • 5.2.1 PROC SORT ??
  • ?? PROC SORT ???
  • PROC SORT?????????
  • DATA???????????
  • OUT ????????,??(???OUT???),????????

27
5.2 ????
  • 5.2.2 BY ??
  • ?? BY DESCENDING ?? ...
  • BY?????????????
  • ?????BY???????,????????DESCENDING???
  • ?BY?????????,????????????,??????????????

28
  • ?
  • data score
  • input class num sex s1-s3 _at__at_
  • totalsum(of s1-s3)
  • cards
  • 1 1001 m 79 96 87
  • 1 1002 f 69 78 92
  • 2 1003 f 68 87 93
  • 1 1004 m 88 93 90
  • 2 1005 m 76 89 88
  • run

29
  • PROC SORT DATASCORE OUTCS2
  • BY CLASS
  • PROC PRINT
  • RUN
  • PROC SORT DATASCORE OUTCS2
  • BY CLASS DESCENDING TOTAL
  • PROC PRINT
  • RUN

30
5.4 ?????
  • SET??????????????????,?????????????????
  • ??SET ????
  • 5.4.1 ????
  • ???????????????,????????????????????
  • 5.4.2 ????
  • ??????????????????????????,????????????????????

31
??
  • DATA TWO
  • SET SCORE CS2
  • PROC PRINT
  • RUN

32
??
  • DATA CS1
  • SET SCORE
  • DROP NUM
  • RUN
  • DATA TWO
  • SET CS1 CS2
  • PROC PRINT
  • RUN

33
  • 5.4.3 ????
  • ???????D1?D2???DEP????,?????????????DEP????????,?
    ??BY?????????
  • ??
  • PROC SORT DATAD1 OUTSORTD1
  • BY DEP
  • PROC SORT DATAD2 OUTSORTD2
  • BY DEP
  • DATA D1D2
  • SET SORTD1 SORTD2
  • BY DEP

34
5.5 ?????
  • MERGE????????SAS??????????????????????????
  • ??MERGE ???? ????
  • 5.5.1 ?????
  • ??BY???,MERGE ?????????????????????????
    MERGE??????????????????????????????????,??????????
    ??????????
  • ???????????????,????????,?????????????????
    ?MERGE?????????????????????

35
???????
  • data student
  • input num name sex
  • cards
  • 89100 lanyin f
  • 89101 hanyang m
  • 89102 sunlin f
  • 89103 zhangli m
  • data test
  • input t1-t3
  • cards
  • 89 76 90
  • 78 88 74
  • 96 98 92
  • data studtest
  • merge student test
  • proc print
  • run

36
  • 5.5.2 ????
  • ???????,??????????????????????????,??????????????
    ???BY????????????
  • ????????(BY??)
  • ???????????????BY????????????????
  • ????????????BY???????,??BY??????????????
    ???????????BY???????????????????????????BY????????
    ,????????????????

37
??????
  • data test
  • input num t1-t3
  • cards
  • 89100 89 76 90
  • 89102 78 88 74
  • 89103 96 98 92
  • proc sort datastudent
  • by num
  • proc sort datatest
  • by num
  • proc print datastudent
  • proc print datatest
  • data mer
  • merge student test
  • by num
  • proc print
  • run

38
5.6 ????
  • ?????,??????PUT???
  • ??PUT ??...
  • ?????????????????????????
  • ???????????? ????????????????????????
  • 1. ???? ?PUT ???,????????
  • ? PUT NAME WEIGHT SEX
  • ???,?????????????
  • 2. ??? ???????????????
  • ?put name 20-30 sex 1 majority 5-15
Write a Comment
User Comments (0)
About PowerShow.com