Below is an example of a short SAS program with excellent comments to help a reader understand the overall purpose of the SAS program as well as the roles of each individual part of the code. You don't need to worry to much about the syntax of this program; just pay attention to how the comments explain the program. Note that I think a great way to "comment" your program is to describe the overall task at the beginning of the program (or beginning of each part of the program), and to add comments near each significant line or section of code as well. ================ SAS Code and Comments Below ======================== /* The following program will perform a quadratic regression in SAS. We will read the data into */ /* a SAS data set, then plot the data. Then we will center the x-variable by subtracting the mean */ /* of the x-values from each x-value, and we will create a quadratic term (the square of the */ /* centered x-values). Finally, we fit the quadratic regression model in PROC REG. */ /* In this data set (taken from Spurrier (1993, Technometrics)), the response is the diameter */ /* of a cornmeal product and the predictor is the percent of sucrose in the product. */ * Creating a SAS data set called corn; DATA corn; * naming the two variables; INPUT sucrpct diameter; * inputting the raw data lines; lines; 0 79 2 65 4 64 6 70 8 78 ; run; /* Checking the shape of the regression relationship */ PROC SGPLOT DATA=corn; * creating a scatter plot with diameter on the y-axis and sucrose percentage on the x-axis; SCATTER y=diameter x=sucrpct; RUN; /* We will center the X variable and also create a "quadratic-term" variable" */ PROC MEANS DATA = corn; * finding summary statistics for the variable "sucrpct"; VAR sucrpct; * creating an output data set "sucrstats" with the mean of the sucrpct values in it; OUTPUT OUT = sucrstats MEAN(sucrpct) = meansucrpct; run; * creating a new data set called corn2; DATA corn2; * a SAS trick to allow the corn2 data set to include the mean of the sucrpct values as a variable; IF _N_=1 THEN SET sucrstats; * the corn2 data set is SET to be based on the corn data set; SET corn; * creating a centered sucrpct variable; csucrpct = sucrpct - meansucrpct; * creating a SQUARED centered sucrpct variable; csucrpctsq = csucrpct**2; run; * Looking at the new data set "corn2" by printing it; PROC PRINT DATA = corn2; run; /* Now we perform the quadratic regression: */ * the regression is performed on the corn2 data set; PROC REG DATA = corn2; * diameter is the dependent variable in the regression model; * centered sucrpct and SQUARED centered sucrpct are the independent variables; MODEL diameter = csucrpct csucrpctsq; RUN; /* A table with parameter estimates and model fit statistics is printed to the results. */ /* There are also some model diagnostic plots printed out automatically. */