Lab 1

  1. Close the Explorer Window and open a new docked Explorer window
  2. Close the Explorer Window.
  3. Open a new Explorer Window
  4. Dock the Explorer Window and unselect the tree view.
  5. Customize the tool bar to include a Find Error Function for the Output Window
  6. With the Log window selected, choose Customize from the Menu Bar
  7. In the Customize Tab, Select Add Tool and Enter:
  8. Command: FIND ERROR;
  9. Help text: Find errors in output
  10. Tip Text: Find Errors
  11. Change the Icon to something meaningful and save the changes.
  12. Highlight the Editor Window and type “This is an error”
  13. Run the code
  14. Select the log window and choose the new icon from the tool bar

Solutions:

Lab 1: Solutions

  1. Close the Explorer Window and open a new docked Explorer window
  2. Close the Explorer Window.
  3. Select the Explorer tab on the Management (Left) Window
  4. Right click on the Explorer tab at the bottom and select close
  5. Open a new Explorer Window
  6. Select the icon resembling a folder with magnifying glass icon from the tool bar OR Select View -> Explorer from the Menu Bar
  7. Dock the Explorer Window and unselect the tree view
  8. With the Explorer window selected, Click on Window Docked
  9. Select View Show tree to unselect the tree view
  10. Customize the tool bar to include a Find Error Function for the Output Window
  11. With the Log window selected, choose Customize from the Menu Bar
  12. Select the Log Window tab from the Programming (right) windows
  13. Select ToolsCustomize from the Menu Bar
  14. Select the Customize Tab from the Customize Tools Window
  15. In the Customize Tab, Select Add Tool by selecting the first icon in the second row
  16. Enter the following, in the 3 fields provided
  17. Command: FIND ERROR;
  18. Help text: Find errors in log
  19. Tip Text: Find Errors
  20. Change the Icon to something meaningful.
  21. Select the 3rd Icon in the second row (square divided into 4 sections)
  22. Scroll through the icons to one you prefer
  23. Select OK
  24. Select OK to complete the customization.
  25. Select Yes to updating the toolbar
  26. Highlight the Editor Window and type “This is an error”
  27. Run the code by selecting Run Submit from the Menu Bar
  28. Select the log window and choose the new icon from the tool bar

Lab 2

  1. Load the following data into a SAS dataset in the Work library by typing the data into a Program. Name the dataset, IceCreamTemp. Name the program Internal Ice Cream.sas

FlavorSizeQuantity Cost

ChocolateSmall51 2.25

VanillaLarge23 4.45

StrawberryLarge34 4.50

RaspberrySmall45 2.20

  1. View the new data set in the Work Library. Why are some of the flavors truncated? Fix this adding the line “length Flavor $20;” before the input line and rerunning the program. (Make sure to close the Viewtable window before rerunning the command.
  1. Create a new library that points to a new directory, Ice Cream, located under the My SAS Files. Name the library IceCream. Set the library to be available automatically on startup.
  2. Copy the dataset, IceCreamTemp, into the IceCream library using a Data Step. Call the new file IceCreamPermanent.
  3. Highlight and copy the data from step 1 above and copy it to a notepad. Save the Notepad as IceCream.txt in you My Documents directory. Write a Data Step to read this file into a data step from the external text file.

Lab 2 Solutions:

  1. Load the following data into a SAS dataset in the Work library by typing the data into a Program. Name the dataset, IceCreamTemp. Name the program Internal Ice Cream.sas

FlavorSizeQuantity Cost

ChocolateSmall51 2.25

VanillaLarge23 4.45

StrawberryLarge34 4.50

RaspberrySmall45 2.20

  • Select File New Program
  • Select File Save As
  • Select My Documents
  • Double click My Sas Files
  • Type Ice Cream under File Name and select Save
  • Type the following program into the Editor:

Data IceCreamTemp;

input Flavor $ Size $ Quantity Cost;

datalines;

Chocolate Small 51 2.25

Vanilla Large 23 4.45

Strawberry Large 34 4.50

Raspberry Small 45 2.20

;

run;

  • Select the Save icon from the tool bar or File Save from the Menu bar.
  • Select Run Submit from the Menu bar or the Run icon from the tool bar.
  • Select the Log tab from programming Window to view your log.
  1. View the new data set in the Work Library. Why are some of the flavors truncated? Fix this adding the line “length Flavor $20;” before the input line and rerunning the program. (Make sure to close the Viewtable window before rerunning the command.
  2. Select the Explorer Window from the Management Tab
  3. Double Click the Libraries Icon
  4. Double Click the Work Icon
  5. Right Click the Icecreamtemp Icon and select Open
  6. View the Dataset and then close the Viewtable window by selecting X from the top right corner
  7. Select the Ice Cream.sas tab from the Programming Window
  8. Before the input line, insert the line:
  9. <length Flavor $20;>
  10. Select Run Submit from the Menu bar or the Run icon from the tool bar.
  11. Select the Log tab from programming Window to view your log.
  12. Select the Explorer Window from the Management Tab
  13. Right Click the Icecreamtemp Icon and select Open
  14. Verify that the flavors are no longer truncated.
  15. Close the viewtable window
  16. Create a new library that points to a new directory, Ice Cream, located under the My SAS Files. Name the library IceCream. Set the library to be available automatically on startup.
  17. Select the explorer tab from the Management Window
  18. Select the New Window icon (filing cabinet) from the tool bar or select Tools New Library from the Menu bar.
  19. Enter IceCream for the Name of the Library
  20. Select the Browse button to the right of the Path
  21. Select My Documents from the list on the left
  22. Double Click My Sas Files
  23. Select the Create new Folder Icon from the top of the window
  24. Enter Ice Cream, click on the new Ice Cream folder and press ok
  25. Select Enable at Startup from the New Library Window
  26. Press Ok
  27. Navigate in the Explorer window until you see the new library
  28. Copy the dataset, IceCreamTemp, into the IceCream library using a Data Step. Call the new file IceCreamPermanent.
  29. Select the Editor - Ice Cream from the Programming window
  30. Beneath the run command enter the following lines:

Data Icecream.Icecreampermanent;

set Icecreamtemp;

run;

  • Select the Save icon from the tool bar or File Save from the Menu bar.
  • Highlight the new code
  • Select the Run icon from the tool bar.
  • Select the Log tab from programming Window to view your log.
  • Find the dataset in the explorer window and view the contents.
  1. Highlight and copy the data from step 1 above and copy it to a notepad. Save the Notepad as IceCream.txt in you My Documents directory. Write a Data Step to read this file into a data set from the external text file . Name the Data set ExternalIceCream and save it directly to the IceCream library.
  2. Select the Editor - Ice Cream from the Programming window
  3. Highlight the data (in yellow) and select the copy icon from the tool bar
  4. Open Notepad from Windows StartProgramsAccessoriesNotepad
  5. Paste the data using Edit Paste
  6. Save it in My Documents as IceCream
  7. Open a new Editor in SAS using File New Program
  8. Enter the following program

Data Icecream.ExternalIceCream;

infile "C:\Documents and Settings\pab699\My Documents\IceCream.txt";

length Flavor $20;

input Flavor $ Size $ Quantity Cost;

run;

  • Run the program, check the log for errors and view the file using the explorer window.

Lab 3:

  1. Using the table editor, open a new table and enter the following data. Save the data in Newlib.Study121. Exit Table editor.

SurnameAge in YearsSex Test 1 ScoreIncome Group

Smith21168h

Brown25273m

Adams29259l

Guest23163l

Jones24171m

Greider29183h

Henkelmeyer31277l

  1. View the Study121 file using table editor.
  2. Sort the table by age.
  3. Change Henkelmeyer to Smith
  4. Add the following row to the table:

SurnameAge in YearsSexTest1 ScoreIncome Group

Jones35271l

  1. Access the form view and add the following line to the table:

SurnameAge in Years SexTest1 ScoreIncome Group

Miller25188h

  1. Exit table editor and view the table using the following print statement in the editor:

Proc print data=Newlib.Study121;

Run;

Lab 3 Solutions:

  1. Using the table editor, open a new table and enter the following data. Save the data in Newlib.Study121. Exit Table editor.

SurnameAge in YearsSex Test 1 ScoreIncome Group

Smith21168h

Brown25273m

Adams29259l

Guest23163l

Jones24171m

Greider29183h

Henkelmeyer31277l

  • Create the library Newlib
  • Select Explorer tab in Management Window
  • Select Tools New Library
  • Name: Newlib
  • X – Enable at Startup
  • Select Browse to right of Path
  • Select My Documents
  • Select New Folder Icon
  • Enter Newlib [Enter]
  • Doubl e Click Newlib and select OK
  • Select OK
  • Verify that Newlib is an active library
  • Select Tools Table Editor from the Menu Bar
  • Enter several rows into the table above
  • Right Click Each Column (i.e. A E), and select column attributes
  • For A, Enter
  • Name:Surname
  • Label: :Last Name
  • Length 20
  • Verify that type each Character
  • Select Apply, Close
  • Repeat for eachcolumn
  • Name Age Label Age in Years
  • Name Sex Label Gender
  • Name Score Label Test 1 Score
  • Name Income Label Income Group
  • Select the save icon or File  Save
  • Select Newlib from the left pane
  • Enter Study121 for Member Name and press Save
  • Select X from the upper Left corner of the window to close viewtable
  1. View the Study121 file using table editor.
  2. Sort the table by age.
  • Select the Explorer tab
  • Choose the Newlib library
  • Double Click on Study 121
  • Select Age in Years and press A-Z from tool bar
  • Read the Warning Message and select No
  • Select Edit Edit Mode
  • Select Age in Years and press A-Z from tool bar
  • Change Henkelmeyer to Smith
  • Select Line 6 First Column
  • Type Smith[Enter[
  • Add the following row to the table:

SurnameAge in YearsSexTest1 ScoreIncome Group

Jones12271l

  1. Select EditAdd Row
  2. Type Row
  3. Right Click and select commit row
  1. Access the form view and add the following line to the table:

SurnameAge in Years SexTest1 ScoreIncome Group

Miller25188h

  • Select View Form View
  • Right Click and select add row
  • Enter Data
  • Right Click and Select Commit Row
  • Select Table View from tool bar
  • Exit table editor and view the table using the following print statement in the editor:

Proc print data=Newlib.Study121;

Run;

  1. Select the Save icon from the tool bar
  2. Select X from the upper right hand corner
  3. Select the Editor tab from the Programming Window
  4. Type the text above
  5. Press the Run icon from the tool bar

Lab 4 Overview:

  1. Start the Analyst tool as a new project.
  2. Copy all of the practice datasets to your new library.
  3. Open the Houses Dataset and save the project as Lab4.
  4. Perform a Summary Statistics by Analyzing price, square feet, bedrooms and baths by the Class-style
  5. Perform a Frequency Analysis on the Houses Dataset for Style, Bedrooms and baths.
  6. Perform a Correlation of square feet to price. Include a scatter plot.

Lab 4 Solutions:

  1. Start the Analyst tool as a new project.
  2. SolutionsAnalysis Analyst
  3. Select New (if applicable)
  4. Copy all of the practice datasets to your new library.
  5. Tools Sample Data
  6. Select all
  7. Choose an existing library to place the data in.
  8. Select libraries <Library Name> to verify that the data sets are copied
  9. Press ok/ok
  10. Open the Houses Dataset and save the project as Lab4.
  11. Select the Analyst window
  12. File open by Sas Name
  13. Select <Library Name> from above
  14. Select Houses
  15. Highlight New Project
  16. Right Click and select Save
  17. Type lab4 and OK
  18. Perform a Summary Statistics by Analyzing price, square feet, bedrooms and baths by the Class-style
  19. Select Statistics Descriptive Summary
  20. Click on price and select Analysis
  21. Repeat with sqfeet, bedrooms and bathrooms
  22. Click on Style and click on class
  23. Select OK
  24. View the output
  25. View the code
  26. Perform a Frequency Analysis on the Houses Dataset for Style, Bedrooms and baths.
  27. Select StatisticsDescriptiveFrequency
  28. Click on Style and select Frequency
  29. Repeat with Bedrooms and baths
  30. Select ok
  31. View output and code
  32. Perform a Correlation of square feet to price. Include a scatter plot
  33. Select StatisticsDescriptiveCorrelation
  34. Click on sqfeet and select Correlation
  35. Repeat with price
  36. Select plots and check off scatter plots
  37. Press ok and ok; view code and plot
  38. Save you work by exiting Analyst and selecting Save

Lab 5: Overview

  1. In the Analyst tool, open the coronary data set and recode the sex column to spell out Male and Female. Name the column Gender.
  2. In the Analyst tool, add a new column to the coronary dataset by using the compute function. Add 10 years to the age column and name the new column age in 10 years.

Lab 5: Problems and Solutions

Summary:

  1. In Analyst, open the coronary data set and recode the sex column to spell out Male and Female. Name the column Gender.
  • Open a new Analyst Project, if you are not in Analyst
  • Select FileOpen by Sas Name
  • Double click the library that holds your sample files
  • Select Coronary and press OK
  • Choose DataTransform
  • Why are the options unselectable?
  • Choose EditModeEdit
  • Choose DataTransformRecode values
  • Choose sex from first pull down
  • Type Gender as the New column name
  • Select Character as New Column Type
  • Press OK
  • Type Female for f
  • Type Male for m
  • Press OK
  • View the new column
  • View the code under Recode Values (Double click the code entry in the tree)
  1. In Analyst, add a new column to the coronary dataset by using the compute function. Add 10 years to the age column and name the new column AgePlus10 .
  • Choose DataTransformCompute
  • Type AgePlus10 in the first box (replace Comp1)
  • Select the variable Age and press the up arrow next the Variables
  • Press the + sign next the edit box
  • Type 10
  • Press OK
  • View the new column
  • View the code under Compute
  • Select Editcopy to program editor

Lab 6 Overview

  1. Using an Enhanced Editor, create a dataset called work.riweights that contains only the records with a weightlifting program of RI.
  2. Using the Import Export Wizard, Export the dataset Protein. Change the First country to Argentina and import as work.improtein.

Lab 6: Problems and Solutions

  1. Using an Enhanced Editor, create a dataset called work.riweights from the weights data set that contains only the records with a weightlifting program of RI.
  2. Using the Explorer window, find the library where you copied the sample data.
  3. View the data by double clicking the library name, weights.
  4. Right click the Weightlifting Program column and view column attributes
  5. Note the name of the column and close the window
  6. Select File New Program to open a new enhanced editor
  7. Type the following code in the enhanced editor:

data work.riweights;

set work.weights;

if program = "RI";

run;

  • Select the Run icon from the tool bar
  • Select the log and look for errors
  • Open the dataset work.riweights and view the data
  1. Using the Import Export Wizard, Export the dataset Protein. Change the First country to Argentina and import as work.improtein.
  2. Select File Export Data
  3. Choose the Library from the first pull down where your sample data sets reside
  4. Choose Protein as the member
  5. Press Next
  6. Press Next to accept Excel as the format
  7. Select the Browse button, choose a directory and name the file eprotein.
  8. Press ok
  9. Type protein1 as the name of the exported table
  10. Press next and select finish
  11. Open the eprotein file in Microsoft
  12. Notice the worksheet name (protein1)
  13. Change Albania in A2 to Argentina
  14. Save the file
  15. In SAS, access FileImport Data
  16. Select Next to choose Excel as the default
  17. Browse to find the saved Excel file and select ok
  18. Select Next to accept protein1 as the table (worksheet)
  19. Type improtein as the member name of the library work
  20. Press Next and Finish
  21. Open the data set improtein in the work library and verify that Argentina is in the first record