1 / 23

Module I: Elementary Data Step Techniques

Module I: Elementary Data Step Techniques. Madan Gopal Kundu. SAS Resources. SAS Procedures guide: http://www.caspur.it/risorse/softappl/doc/sas_docs/proc/index.htm The Little SAS Book by Lora D Delwiche and Susan J Slaughter http://www.ats.ucla.edu/stat/sas/notes2/.

chapa
Download Presentation

Module I: Elementary Data Step Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Module I: Elementary Data Step Techniques Madan Gopal Kundu

  2. SAS Resources • SAS Procedures guide: http://www.caspur.it/risorse/softappl/doc/sas_docs/proc/index.htm • The Little SAS Book by Lora D Delwiche and Susan J Slaughter • http://www.ats.ucla.edu/stat/sas/notes2/

  3. Introduction • Statistical Analysis System • Developed by Jim Goodnight in1970 at N.C. University for Agricultural Research • SAS Institute founded in 1976 • 98 of world’s top 100 company in Fortune 500 use SAS • SAS Macro facility

  4. SAS Windows To write/ modify SAS program code • Editor • Log • Output • Result • Explorer • Graph • To check execution of the program. • Helps in identify the error in SAS code • Tells about details such as amount of time it taken to execute the code It displays the output generated upon execution of SAS code It displays index of the output It displays the list of libraries (containing SAS dataset), formats, compiled macros and graphs It displays graph

  5. EXPLORER OUTPUT RESULT LOG EDITOR

  6. Layout of SAS Programs • SAS statement can be in upper- or lower case • All statements end with semicolon (;) • Statement can continue on the next line • Statements can be on the same line as other statements • Statements can start on any column

  7. Statement to generate library Name of the library Path of the library Crating SAS Library • Programmatically – Using LIBNAME statement • LIBNAME newlib ‘C:\’; • Non-programmatically

  8. Variable name • Maximum 32 characters • Must start with a letter or an underscore • Contain only letters, numerals or underscores • Can contain upper- and lower case letters • Character variables always followed by $

  9. Creating Datasets in SAS • Using Data step DATA newlib.one; INPUT name $ roll score; CARDS; Ramen 122 95 Chris 123 84 Neha 124 90 Abdul 125 91 ; RUN; ?? newlib.one : The dataset ONE is in the library NEWLIB

  10. Importing Data in SAS • Import Wizard • Proc import • Data step

  11. Existing dataset Create SAS Dataset from already existing SAS dataset… DATA two; SET one; RUN; New dataset

  12. Managing SAS dataset • SET statement • KEEP statement • DROP statement • RENAME statement • WHERE statement • DELETE statement • LABEL statement

  13. KEEP statement DATA new; SET sashelp.class; KEEP name sex age; RUN; It will keep only the selected variables. Remaining variables will be dropped.

  14. DROP statement DATA new; SET sashelp.class; DROP name sex age; RUN; It will drop all the selected variables. Remaining variables will be as such.

  15. RENMAE statement DATA new; SET sashelp.class; RENAME Sex=Gender; RUN; Used to change the variable name.

  16. LABEL statement DATA new; SET sashelp.class; LABEL Age=‘Age (Yrs)’ Weight=‘Weight (Kg)’; RUN; Used to label the variable names.

  17. WHERE statement DATA new; SET sashelp.class; WHERE sex=‘F’; RUN; Used to add some condition to the dataset.

  18. WHERE statement DATA new; SET sashelp.class; WHERE Age>13; RUN; Used to add some condition to the dataset.

  19. Merging datasets • Sort the dataset using PROC SORT • Merge the datasets in datastep

  20. Merging datasets ONE TWO + FINAL

  21. Merging datasets

  22. SAS System options • CENTER| NOCENTER • DATE|NODATE • LINESIZE=n (64-256) • PAGESIZE=n (15-32767) • PAGENO=n • RIGHTMARGIN=n • LEFTMARGIN=n • TOPMARGIN=n • BOTTOMMARGIN=n

  23. Task… • Create a library in SAS • Create the following SAS dataset • Get a copy of that dataset using SET statement • Label the variable WT as ‘Weight (kg)’

More Related