1.3 Understanding SAS Program Syntax
1.3 Understanding SAS Program Syntax
1.3 Understanding SAS Program Syntax
Print
1. Open the p101d02.sas program from the demos folder. The program is not spaced well. It has
multiple statements on a single line and the indention of certain statements is inconsistent.
AvgMPG=mean(mpg_city, mpg_highway);
run;
RUN;TITLE;
2. Submit the program to see if it runs correctly. The program runs without any warnings or errors.
3. Go back to the code. Click the Format Code button or right-click in the program and select
Format Code.
4. Next we'll add some comments to the code. Add the following text before the DATA statement:
Program created by < your-name > . Next, highlight the text and press Ctrl and forward slash (/) to
automatically surround it with the comment symbols, /* and */.
5. Although you haven't learned about the syntax yet, there is a WHERE statement in the code that is
subsetting the data for AvgMPG greater than 35, and there is a corresponding title that indicates
that the data has been subset. Comment out the first TITLE statement and the WHERE statement
in PROC PRINT by putting an asterisk in front of each statement.
6. Run the code and verify that there is no title in the report and the AvgMPG column has values less
than 35.
Solution code:
/*Program created by */
data mycars;
set sashelp.cars;
AvgMPG=mean(mpg_city, mpg_highway);
run;
run;
var avgmpg;
class type;
run;
title;
Submit
Copyright © 2021 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Close