Copy of SAS Programming Module Eleven Lesson One Activity

.pdf

School

North Carolina State University *

*We aren’t endorsed by this school

Course

15

Subject

Statistics

Date

Nov 24, 2024

Type

pdf

Pages

4

Uploaded by GrandGalaxyDolphin7

Report
Google File Access Directions: Please click on File in the upper left corner. If you are working on a Chromebook or Google Docs, choose the Make a copy option and save a copy of the document to your Google Drive. If not, choose the Download as option and then the Microsoft Word (.docx) option to download an editable copy of the document to your computer. Module Eleven Lesson One Activity Open p204a01.sas from the activities folder and perform the following tasks: 1. Add a FORMAT statement in the DATA step to format the following values: Date Use MONYY7. to display three-letter month and four-digit year values. Volume Use COMMA12. to add commas. CloseOpenDff HighLowDiff Use DOLLAR8.2 to add dollar signs and include two decimal places. 2. Run the program and verify the formatted values in the PROC PRINT output. 3. Add a FORMAT statement in the PROC MEANS step to format the values of Date to show only a four-digit year. Run the PROC MEANS step again. 4. What is the advantage of adding a FORMAT statement to the DATA step versus the PROC step? The advantage of adding a FORMAT statement to the DATA step versus the PROC step is if you would want the entire dataset to be formatted the same. The format will not need to be reapplied each time. %let path=~/EPG294/data; libname PG2 "&path"; data work.stocks; set pg2.stocks; CloseOpenDiff=Close-Open; HighLowDiff=High-Low; format Date monyy7. Volume comma12. CloseOpenDiff HighLowDiff dollar8.2; run;
proc print data=stocks (obs=5); var Stock Date Volume CloseOpenDiff HighLowDiff; run; proc means data=stocks maxdec=0 nonobs mean min max; class Stock Date; var Open; format Date year4.; run; Open p204a02.sas from the activities folder and perform the following tasks: 1. In the PROC FORMAT step, modify the second VALUE statement to create a format named HRANGE that has the following criteria: A range of 50 – 57 has a formatted value of Below Average . A range of 58 – 60 has a formatted value of Average . A range of 61 – 70 has a formatted value of Above Average . 2. In the PROC PRINT step, modify the FORMAT statement to format Height with the HRANGE format. 3. Run the program and verify the formatted values in the PRINT output. 4. Why is the Height value for the first row not formatted? The Height value for the first row is not formatted because it does not fall within the specified ranges of the HRANGE format. %let path=~/EPG294/data; libname PG2 "&path"; proc format; value $genfmt 'F'='Female' 'M'='Male';
value hrange 50-57='Below Average' 58-60='Average' 61-70='Above Average'; proc print data=pg2.class_birthdate noobs; where Age=12; var Name Gender Height; format Gender $genfmt. Height hrange.; run; Open p204a03.sas from the activities folder and perform the following tasks: 1. Review the PROC FORMAT step that creates the $REGION format that assigns basin codes to groups. Highlight the step and run the selected code. 2. Notice that the DATA step includes IF-THEN/ELSE statements to create a new column named BasinGroup . 3. Delete the IF-THEN/ELSE statements and replace them with an assignment statement to create the BasinGroup column. Use the PUT function with Basin as the first argument and $REGION. as the second argument. 4. Highlight the DATA and PROC MEANS steps and run the selected code. How many BasinGroup values are in the summary report. %let path=~/EPG294/data; libname PG2 "&path"; proc format; value $region 'NA'='Atlantic' 'WP','EP','SP'='Pacific' 'NI','SI'='Indian' ' '='Missing' other='Unknown';
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
run; data storm_summary; set pg2.storm_summary; Basin=upcase(Basin); BasinGroup=put(Basin, $region.); run; proc means data=storm_summary maxdec=1; class BasinGroup; var MaxWindMPH MinPressure; run;