Getting started in SAS with the Old-Growth Forest Case Study

2001-04-03

Create a folder on stats for your Forestry SAS project. Inside that folder, create a new folder called 'forestlib' that will hold your SAS data library.

Go to the Old Growth Forest Case Study at

http://www.math.mcmaster.ca/peter/sora/case_studies_01/forestry.html

Save the data file as a text file 'forest.txt' in the project folder you created on stats. Launch SAS from the project folder and use the Program Editor to write the following script. Save the script, then Submit it.

The script attaches the logical name forest to the library folder 'forestlib' and the logical name myfile to the data file 'forest.txt'. It creates forest.mytrees, which is a SAS data object called mytrees inside the library forest.

The infile command says to read from myfile, skipping the first line, fixed-width record format, each line 90 characters long (counting the <CR> at the end of the line).

The input command specifies that variable tag is to be taken from the 10-column numeric field beginning at column 1, variable species is to be taken from the 2-column character field beginning at column 18, etc. The run command runs the script.

libname forest 'forestlib';
  filename myfile 'forest.txt';
  data forest.mytrees;
  infile myfile firstobs=2 recfm=f lrecl=90 linesize=90;
  input
  @1 tag 10.
  @18 species $2.
  @20 x 11.
  @31 y 10.
  @41 z 10.
  @51 dbh 10.
  @61 htt 10.
  @71 htb 10.
  @82 status $9.;
run;
quit;

Now that the data structure is in the library, the following script finds it and opens it with the exploratory tool proc insight. Try various box plots, contour plots, rotating plots, scatter plots, etc.

libname forest 'forestlib';
  proc insight data=forest.mytrees;
run;

Statistics 4P03