Online File

#### Chapter 4 Program 4b Planets compared to dwarf planets

##### Tentative

This version of the program contains errors that are corrected in an exercise in the book.

```*
Professional SAS Programming Secrets
Program 4b (tentative)
Planets compared to dwarf planets
*;

filename planets "planet1.csv";
filename dwarf "dwarfplanet1.csv";

data work.planet;
length planet \$ 16 sequence mass radius 8;
infile planets dsd;
run;

data work.dwarf;
length planet \$ 16 sequence mass radius 8;
infile dwarf dsd;
run;

*
Combine data.
*
data work.orbital;
length bodytype \$ 12;
set work.planet (in=big) work.dwarf (in=small);
if big then body = 'Planet';
else body = 'Dwarf Planet';
log_mass = log10(mass) + 21;
run;

*
Summary statistics.
*;
title1 'Planets and Dwarf Planets';
proc summary data=work.orbital nway
print n mean min max;
class bodytype;
run;

*
Plots.
*;
options nocenter;
proc plot data=work.orbital;
run;
run;
quit;
```

##### Final

The final, corrected version of the program.

```*
Professional SAS Programming Secrets
Program 4b
Planets compared to dwarf planets
*;

filename planets "planet1.csv";
filename dwarf "dwarfplanet1.csv";

data work.planet;
length planet \$ 16 sequence mass radius 8;
infile planets dsd;
run;

data work.dwarf;
length planet \$ 16 sequence mass radius 8;
infile dwarf dsd;
run;

*
Combine data.
*;
data work.orbital;
length bodytype \$ 12;
set work.planet (in=big) work.dwarf (in=small);
if big then bodytype = 'Planet';
else bodytype = 'Dwarf Planet';
log_mass = log10(mass) + 21;
run;

*
Summary statistics.
*;
title1 'Planets and Dwarf Planets';
proc summary data=work.orbital nway
print n mean min max;
class bodytype;
run;

*
Plots.
*;
options nocenter;
proc plot data=work.orbital;
run;
run;
quit;
```

##### Data

These initial steps from the program create SAS data sets that are used in other programs throughout the book.

```*
Professional SAS Programming Secrets
Program 4b-data steps
Planets compared to dwarf planets
*;

filename planets "planet1.csv";
filename dwarf "dwarfplanet1.csv";

data work.planet;
length planet \$ 16 sequence mass radius 8;
infile planets dsd;
run;

data work.dwarf;
length planet \$ 16 sequence mass radius 8;
infile dwarf dsd;
run;

*
Combine data.
*;
data work.orbital;
length bodytype \$ 12;
set work.planet (in=big) work.dwarf (in=small);
if big then bodytype = 'Planet';
else bodytype = 'Dwarf Planet';
log_mass = log10(mass) + 21;
run;
```