NOTE: There were 74 observations read from the data set SQL.FEATURES.
NOTE: The data set WORK.OCEAN has 4 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: There were 74 observations read from the data set SQL.FEATURES.
NOTE: The data set WORK.RIVER has 12 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds
NOTE: There were 74 observations read from the data set SQL.FEATURES.
NOTE: The data set WORK.SEA has 13 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.02 seconds
NOTE: There were 74 observations read from the data set SQL.FEATURES.
NOTE: The data set WORK.WATERFALL has 4 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds
How It Works
This solution uses the INTO clause to store values in macro variables. The first SELECT
statement counts the unique variables and stores the result in macro variable N. The
second SELECT statement creates a range of macro variables, one for each unique
value, and stores each unique value in one of the macro variables. Note the use of the
%LEFT function, which trims leading blanks from the value of the N macro variable.
The MAKEDS macro uses all the macro variables that were created in the PROC SQL
step. The macro uses a %DO loop to execute a DATA step for each unique value, writing
rows that contain a given value of Type to a SAS data set of the same name. The Type
variable is dropped from the output data sets.
For more information about SAS macros, see SAS Macro Language: Reference.
Using PROC SQL Tables in Other SAS
Procedures
Problem
You want to show the average high temperatures in degrees Celsius for European
countries on a map.
Background Information
The Sql.WorldTemps table has average high and low temperatures for various cities
around the world.
proc sql outobs=10;
title 'WorldTemps';
208 Chapter 6 • Practical Problem-Solving with PROC SQL