SAS Software Overview and Data Management

Sep 13, 2024

Lecture Notes: SAS Software and Data Management

Introduction to SAS Software

  • SAS 4.9.4 desktop software available for Windows users at can.edu.
  • Free for KSU users; requires login and download.
  • Software download: 11 GB zip file; extract and run setup for installation.
  • Orientation lecture available online for further guidance.

Alternative Options for Mac Users

  • VM Fusion:

    • Free for personal use; allows installation of Windows software on Mac.
    • Two versions: Fusion Pro and Workstation available; choose based on Mac's hardware (Intel vs. Apple Silicon).
    • Installation involves downloading Windows from Microsoft and setting up VM tools.
  • SAS Studio (Online Version):

    • Accessible to KSU users; suitable for basic class needs but not advanced level.
    • Syntax is similar to desktop SAS software.

SAS Environment and Setup

  • Creating a Library in SAS:

    • Use libname keyword to create a permanent library.
    • Example: libname clinic 'path-to-folder';
    • Store path to a directory in your system where SAS datasets will be kept.
  • Data Portability:

    • Copy datasets between libraries using data and set statements.
    • Example: data clinic.new_dataset; set clinic.existing_dataset; run;

Coding in SAS

  • Basic Syntax:

    • Every statement ends with a semicolon ;.
    • Comments can be added using * comment text; or /* comment text */.
  • Data Components:

    • SAS datasets consist of descriptor (metadata) and data portions (actual data).
    • Variables can be numeric or character; missing numeric values are denoted by a . and character by a blank.

Practical SAS Functions

  • Printing and Summarizing Data:

    • proc print data=library.dataset; run; prints data.
    • proc contents data=library.dataset; run; prints metadata.
  • Creating New Variables:

    • Use expressions to create new columns.
    • Example: data new_dataset; set old_dataset; new_var = old_var / 2; run;

Importing and Exporting Data

  • Importing Excel Data: Proc Import

    • Use proc import to load Excel files into SAS datasets.
    • Example: proc import datafile='path' out=library.dataset dbms=xlsx replace; sheet='Sheet1'; run;
  • Exporting to Excel or CSV: Proc Export

    • Use proc export to save datasets to Excel or CSV.
    • Example for CSV: proc export data=library.dataset outfile='path' dbms=csv replace; run;

Advanced Features and Tips

  • VM Tools for Mac Users:
    • Install additional VM tools for better performance.
    • Necessary for installing SAS on a virtual Windows environment.

Conclusion

  • Practice coding regularly; document code with comments for future reference.
  • Engage with provided resources and reach out for support if needed.
  • Use the class time efficiently to explore SAS functionalities and understand the environment.