Please help me with the Level 2 practice question in Week 5_Creating Summary Reports and Data.
I'm confused with the second question (continue with the first question).
Here are the instructions.
1. Write a PROC PRINT step to print the rainstats table.
2. Suppress the printing observation numbers, and display column labels.
3. Display the columns in the following order: Name, Year, RainDays, and TotalRain.
4. Label Name as Park Name, RainDays as Number of Days Raining, and TotalRain as Total Rain Amount(inches).
5. Use Rain Statistics by Year and Park as the report title.
6. Submit the program and review the results.
<My Answer>
title "Rain Statistics by Year and Park";
proc print data=rainstats noobs label;
keep Name Year RainDays TotalRain;
label Name="Park Name" RainDays="Number of Days Raining"
TotalRain="Total Rain Amount(inches)";
run;
title;
<Answer>
title "Rain Statistics by Year and Park";
proc print data=rainstats noobs label;
var Name Year RainDays TotalRain;
label Name="Park Name" RainDays="Number of Days Raining"
TotalRain="Total Rain Amount(inches)";
run;
title;
I'm confused with the usage of keep and var statement.
According to SAS document, keep statement specifies the variables to include in output SAS data sets.
Can anyone explain the difference between keep and var statement?
Thank you very much.
The PRINT procedure does not support the KEEP statement. That is really only used in a DATA step. Plus even if it DID work it would not have any impact on the order of the variables.
The PRINT procedure does support the VAR statement. You use it to list the variables that you want to print.
The PRINT procedure does not support the KEEP statement. That is really only used in a DATA step. Plus even if it DID work it would not have any impact on the order of the variables.
The PRINT procedure does support the VAR statement. You use it to list the variables that you want to print.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.