BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
easthill93
Calcite | Level 5

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.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1338 views
  • 0 likes
  • 2 in conversation