Download as:
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Language:EN
Pages: 36
Words: 1662

Directing data step output

LECTURE#8: Controlling DATA Step Processing

  1. Controlling Row Output 1-22

  2. Controlling Column Output 1-25

Setting Up for This Course

The complete SAS programming process includes accessing data, exploring and validating data, preparing data, analyzing and reporting on data, and exporting results. But it is likely that the majority of your time as a programmer is spent preparing data. For this reason, the rest of the course is focused on the SAS DATA step and various procedures that expand your skills and help make you more productive working with your data.

  • In “Creating Custom Formats,” you learn how to create and use custom formats to enhance how your data is displayed in a table or report.

  • In “Combining Tables,” you learn how to concatenate tables, merge tables, and identify matching and nonmatching rows.

Understanding DATA Step Processing

Practice

Level 1

      1. What will be assigned for the length of Size?

    1. Run the program and examine the results.

      1. At the end of the DATA step, write the contents of the PDV to the log.

    2. Run the program and read the log to examine the messages written during execution.

Directing DATA Step Output

Controlling Row Output

Scenario
Files
  • p201d02.sas

  • storm_summary – a SAS table that has one row per storm for the 1980 through 2016 storm seasons

Notes
  • The OUTPUT statement followed by a table name writes the contents of the PDV to the specified table.

Demo
  1. Open the p201d02.sas program in the demos folder and find the Demo section. Modify the DATA statement to create three tables named indian, atlantic, and pacific.

length Ocean $ 8;

Basin=upcase(Basin);

output indian;

end;

else do;

Ocean="Pacific";

drop MaxWindMPH;

End of Demo

Controlling Column Output

Scenario
Files
  • storm_summary – a SAS table that has one row per storm for the 1980 through 2016 storm seasons

Notes
  • DROP= or KEEP= data set options can be added on any table in the DATA statement.

Demo
  1. Add a DROP= data set option in the SET statement to drop MinPressure. Start the debugger. Notice that MinPressure is not included in the PDV.

set pg2.storm_summary(drop=MinPressure);

Practice

If you restarted your SAS session, open and submit the libname.sas program in the course files.

Level 1

  1. Submit the program and verify the output.

    The notes in the SAS log indicate how many rows are in each table.

Level 2

  1. Conditionally Creating Columns and Output Tables

The pg2.np_2017 table contains monthly public use figures for national parks.

    1. contains the ParkName, Month, DayVisits, and CampTotal columns

  1. The lodging table has the following specifications:

NOTE: The data set WORK.LODGING has 383 observations and 4 variables.

Challenge

  1. Processing Statements Conditionally with SELECT-WHEN Groups

End of Practice

HOME WORK#7:

Solutions

Solutions to Activities and Questions

Copyright © 2009-2023 UrgentHomework.com, All right reserved.