Resources

SAS Studio: Help Center


How do I run a SAS program?

Let's run a sample SAS program and view the results. This program creates a new SAS table from an existing SAS table. The new table includes only a subset of rows from the existing table.

Note The Sashelp library contains sample SAS tables that you can use as you learn about SAS. You can learn more about SAS libraries and accessing data.
  1. Copy and paste or type the following code into the program editor in SAS Studio. If you need to create a new program window, open the Server Files and Folders section of the navigation pane. Then click New SAS program button and select SAS Program.
    data work.teenstudents;
        set sashelp.class;
    	where age > 12;
    run;
    
    proc print data=work.teenstudents;
    run;
    

  2. Notice that when you paste this text into the program editor, SAS keywords are color-coded. You can right-click a keyword to view detailed syntax help.

    Program editor with sample SAS program

    The DATA step creates a new SAS table named Teenstudents in the temporary Work library. The Teenstudents table is created from rows in the Class table in which the value of Age is greater than 12.

    The PROC PRINT step lists all of the data in the Teenstudents table.

  3. Click Run button to run the program. The Results tab opens automatically.

    Results showing listing of data from Teenstudents table

    The results in SAS Studio are easy to use, but what if you need them in a different format so that you can share them with someone else? By clicking the appropriate button on the Results toolbar, you can download your results as an HTML, PDF, or RTF file, and save them or open them in the default application for that format.