Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
SAS tutorial 10/25
Overview• PROC SUMMARY• PROC SORT• LABEL• GOTO
SUMMARY & SORT
PROC SUMMARY• Provides data summarization tools that  compute descriptive statistics for variables  across all observation...
Syntax
Differences to MEANS• Cannot do t-test• Cannot calculate confidence limits• Cannot estimate quantiles
Example 1
DATA creativity
Result
Use “BY” option
“Not sorted in ascending       sequence”
PROC SORT• Orders SAS data set observations by the  values of one or more character or numeric  variables
Syntax
Example 2
Result
Example 1
Result
LABEL & GOTO
GOTO• Directs program execution immediately to the  statement label that is specified and, if  followed by a RETURN statem...
(Statement) Label• Specifies a statement label that identifies the  GOTO destination. The destination must be  within the ...
Example 3
• DATA info;                • DATA info;  Input X Y;                  Input X Y;  If 1<=X<=5 then             If X<1 or X>...
Result
Return
• DATA info;                         • DATA info;  Input X Y;                           Input X Y;  If 1<=X<=5 then go to ...
Result
1025 sas實習課
Upcoming SlideShare
Loading in …5
×

1025 sas實習課

242 views

Published on

  • Be the first to comment

  • Be the first to like this

1025 sas實習課

  1. 1. SAS tutorial 10/25
  2. 2. Overview• PROC SUMMARY• PROC SORT• LABEL• GOTO
  3. 3. SUMMARY & SORT
  4. 4. PROC SUMMARY• Provides data summarization tools that compute descriptive statistics for variables across all observations or within groups of observations.• Similar to PROC MEANS
  5. 5. Syntax
  6. 6. Differences to MEANS• Cannot do t-test• Cannot calculate confidence limits• Cannot estimate quantiles
  7. 7. Example 1
  8. 8. DATA creativity
  9. 9. Result
  10. 10. Use “BY” option
  11. 11. “Not sorted in ascending sequence”
  12. 12. PROC SORT• Orders SAS data set observations by the values of one or more character or numeric variables
  13. 13. Syntax
  14. 14. Example 2
  15. 15. Result
  16. 16. Example 1
  17. 17. Result
  18. 18. LABEL & GOTO
  19. 19. GOTO• Directs program execution immediately to the statement label that is specified and, if followed by a RETURN statement, returns execution to the beginning of the DATA step.
  20. 20. (Statement) Label• Specifies a statement label that identifies the GOTO destination. The destination must be within the same DATA step. You must specify the label argument.
  21. 21. Example 3
  22. 22. • DATA info; • DATA info; Input X Y; Input X Y; If 1<=X<=5 then If X<1 or X>5 then do; go to OK; X=3; count+1; X=3; count+1; end; OK:SUMX+X; SUMX+X; Cards; Cards; X1 X1’ SUMX 1 1 1 2 2 3 6 3 6 4 4 10 7 3 13 1 1 14
  23. 23. Result
  24. 24. Return
  25. 25. • DATA info; • DATA info; Input X Y; Input X Y; If 1<=X<=5 then go to If X<1 or X>5 then do; OK; X=3; count+1; X=3; count+1; Return; End; OK:SUMX+X; else SUMX+X; Cards; X1 X1’ SUMX Cards; 1 1 1 2 2 3 6 3 3 4 4 7 7 3 7 1 1 8
  26. 26. Result

×