Lab 1
- Close the Explorer Window and open a new docked Explorer window
- Close the Explorer Window.
- Open a new Explorer Window
- Dock the Explorer Window and unselect the tree view.
- Customize the tool bar to include a Find Error Function for the Output Window
- With the Log window selected, choose Customize from the Menu Bar
- In the Customize Tab, Select Add Tool and Enter:
- Command: FIND ERROR;
- Help text: Find errors in output
- Tip Text: Find Errors
- Change the Icon to something meaningful and save the changes.
- Highlight the Editor Window and type “This is an error”
- Run the code
- Select the log window and choose the new icon from the tool bar
Solutions:
Lab 1: Solutions
- Close the Explorer Window and open a new docked Explorer window
- Close the Explorer Window.
- Select the Explorer tab on the Management (Left) Window
- Right click on the Explorer tab at the bottom and select close
- Open a new Explorer Window
- Select the icon resembling a folder with magnifying glass icon from the tool bar OR Select View -> Explorer from the Menu Bar
- Dock the Explorer Window and unselect the tree view
- With the Explorer window selected, Click on Window Docked
- Select View Show tree to unselect the tree view
- Customize the tool bar to include a Find Error Function for the Output Window
- With the Log window selected, choose Customize from the Menu Bar
- Select the Log Window tab from the Programming (right) windows
- Select ToolsCustomize from the Menu Bar
- Select the Customize Tab from the Customize Tools Window
- In the Customize Tab, Select Add Tool by selecting the first icon in the second row
- Enter the following, in the 3 fields provided
- Command: FIND ERROR;
- Help text: Find errors in log
- Tip Text: Find Errors
- Change the Icon to something meaningful.
- Select the 3rd Icon in the second row (square divided into 4 sections)
- Scroll through the icons to one you prefer
- Select OK
- Select OK to complete the customization.
- Select Yes to updating the toolbar
- Highlight the Editor Window and type “This is an error”
- Run the code by selecting Run Submit from the Menu Bar
- Select the log window and choose the new icon from the tool bar
Lab 2
- 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
- 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.
- 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.
- Copy the dataset, IceCreamTemp, into the IceCream library using a Data Step. Call the new file IceCreamPermanent.
- 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:
- 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.
- 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.
- Select the Explorer Window from the Management Tab
- Double Click the Libraries Icon
- Double Click the Work Icon
- Right Click the Icecreamtemp Icon and select Open
- View the Dataset and then close the Viewtable window by selecting X from the top right corner
- Select the Ice Cream.sas tab from the Programming Window
- Before the input line, insert the line:
- <length Flavor $20;>
- 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.
- Select the Explorer Window from the Management Tab
- Right Click the Icecreamtemp Icon and select Open
- Verify that the flavors are no longer truncated.
- Close the viewtable window
- 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.
- Select the explorer tab from the Management Window
- Select the New Window icon (filing cabinet) from the tool bar or select Tools New Library from the Menu bar.
- Enter IceCream for the Name of the Library
- Select the Browse button to the right of the Path
- Select My Documents from the list on the left
- Double Click My Sas Files
- Select the Create new Folder Icon from the top of the window
- Enter Ice Cream, click on the new Ice Cream folder and press ok
- Select Enable at Startup from the New Library Window
- Press Ok
- Navigate in the Explorer window until you see the new library
- Copy the dataset, IceCreamTemp, into the IceCream library using a Data Step. Call the new file IceCreamPermanent.
- Select the Editor - Ice Cream from the Programming window
- 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.
- 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.
- Select the Editor - Ice Cream from the Programming window
- Highlight the data (in yellow) and select the copy icon from the tool bar
- Open Notepad from Windows StartProgramsAccessoriesNotepad
- Paste the data using Edit Paste
- Save it in My Documents as IceCream
- Open a new Editor in SAS using File New Program
- 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:
- 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
- View the Study121 file using table editor.
- Sort the table by age.
- Change Henkelmeyer to Smith
- Add the following row to the table:
SurnameAge in YearsSexTest1 ScoreIncome Group
Jones35271l
- Access the form view and add the following line to the table:
SurnameAge in Years SexTest1 ScoreIncome Group
Miller25188h
- Exit table editor and view the table using the following print statement in the editor:
Proc print data=Newlib.Study121;
Run;
Lab 3 Solutions:
- 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
- View the Study121 file using table editor.
- 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
- Select EditAdd Row
- Type Row
- Right Click and select commit row
- 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;
- Select the Save icon from the tool bar
- Select X from the upper right hand corner
- Select the Editor tab from the Programming Window
- Type the text above
- Press the Run icon from the tool bar
Lab 4 Overview:
- Start the Analyst tool as a new project.
- Copy all of the practice datasets to your new library.
- Open the Houses Dataset and save the project as Lab4.
- Perform a Summary Statistics by Analyzing price, square feet, bedrooms and baths by the Class-style
- Perform a Frequency Analysis on the Houses Dataset for Style, Bedrooms and baths.
- Perform a Correlation of square feet to price. Include a scatter plot.
Lab 4 Solutions:
- Start the Analyst tool as a new project.
- SolutionsAnalysis Analyst
- Select New (if applicable)
- Copy all of the practice datasets to your new library.
- Tools Sample Data
- Select all
- Choose an existing library to place the data in.
- Select libraries <Library Name> to verify that the data sets are copied
- Press ok/ok
- Open the Houses Dataset and save the project as Lab4.
- Select the Analyst window
- File open by Sas Name
- Select <Library Name> from above
- Select Houses
- Highlight New Project
- Right Click and select Save
- Type lab4 and OK
- Perform a Summary Statistics by Analyzing price, square feet, bedrooms and baths by the Class-style
- Select Statistics Descriptive Summary
- Click on price and select Analysis
- Repeat with sqfeet, bedrooms and bathrooms
- Click on Style and click on class
- Select OK
- View the output
- View the code
- Perform a Frequency Analysis on the Houses Dataset for Style, Bedrooms and baths.
- Select StatisticsDescriptiveFrequency
- Click on Style and select Frequency
- Repeat with Bedrooms and baths
- Select ok
- View output and code
- Perform a Correlation of square feet to price. Include a scatter plot
- Select StatisticsDescriptiveCorrelation
- Click on sqfeet and select Correlation
- Repeat with price
- Select plots and check off scatter plots
- Press ok and ok; view code and plot
- Save you work by exiting Analyst and selecting Save
Lab 5: Overview
- In the Analyst tool, open the coronary data set and recode the sex column to spell out Male and Female. Name the column Gender.
- 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:
- 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 FileOpen by Sas Name
- Double click the library that holds your sample files
- Select Coronary and press OK
- Choose DataTransform
- Why are the options unselectable?
- Choose EditModeEdit
- Choose DataTransformRecode 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)
- 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 DataTransformCompute
- 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 Editcopy to program editor
Lab 6 Overview
- Using an Enhanced Editor, create a dataset called work.riweights that contains only the records with a weightlifting program of RI.
- 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
- 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.
- Using the Explorer window, find the library where you copied the sample data.
- View the data by double clicking the library name, weights.
- Right click the Weightlifting Program column and view column attributes
- Note the name of the column and close the window
- Select File New Program to open a new enhanced editor
- 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
- Using the Import Export Wizard, Export the dataset Protein. Change the First country to Argentina and import as work.improtein.
- Select File Export Data
- Choose the Library from the first pull down where your sample data sets reside
- Choose Protein as the member
- Press Next
- Press Next to accept Excel as the format
- Select the Browse button, choose a directory and name the file eprotein.
- Press ok
- Type protein1 as the name of the exported table
- Press next and select finish
- Open the eprotein file in Microsoft
- Notice the worksheet name (protein1)
- Change Albania in A2 to Argentina
- Save the file
- In SAS, access FileImport Data
- Select Next to choose Excel as the default
- Browse to find the saved Excel file and select ok
- Select Next to accept protein1 as the table (worksheet)
- Type improtein as the member name of the library work
- Press Next and Finish
- Open the data set improtein in the work library and verify that Argentina is in the first record