Fundamentals of Programming in SAS. James Blum

Читать онлайн книгу.

Fundamentals of Programming in SAS - James Blum


Скачать книгу
Identifiable42927970.2800.0668.5100.07400.0Not in Metro Area97603815.0670.0576.0100.06800.0Metro, Inside City560391363.51100.0974.8100.07400.0Metro, Outside City1859671480.81300.0974.7100.07400.0Metro, City Status Unknown1632041233.21000.0846.4100.07400.0

      Output 2.2.2: Minimum, Median, and Maximum on Mortgage Payments Across Multiple Categories

MetroHousehold IncomeVariableLabelMinimumMedianMaximum
Metro, Inside CityNegativeMortgagePaymentHomeValueMortgage PaymentHome Value4407000012002500004500675000
$0 to $45KMortgagePaymentHomeValueMortgage PaymentHome Value100074013000068005303000
$45K to $90KMortgagePaymentHomeValueMortgage PaymentHome Value1000100018000074004915000
Above $90KMortgagePaymentHomeValueMortgage PaymentHome Value1000160034000074005303000
Metro, Outside CityNegativeMortgagePaymentHomeValueMortgage PaymentHome Value10010000145025000054004152000
$0 to $45KMortgagePaymentHomeValueMortgage PaymentHome Value100085015000074004304000
$45K to $90KMortgagePaymentHomeValueMortgage PaymentHome Value1000110019900068004915000
Above $90KMortgagePaymentHomeValueMortgage PaymentHome Value1000160033000074004915000
Metro, City Status UnknownNegativeMortgagePaymentHomeValueMortgage PaymentHome Value18017000120024500053002948000
$0 to $45KMortgagePaymentHomeValueMortgage PaymentHome Value100072012500074004915000
$45K to $90KMortgagePaymentHomeValueMortgage PaymentHome Value100096016000074004915000
Above $90KMortgagePaymentHomeValueMortgage PaymentHome Value1000140027000074004915000

      In Outputs 2.2.3 and 2.2.4, frequencies and percentages are summarized across combinations of various categories, which requires mastery of the fundamentals of the FREQ procedure.

      Output 2.2.3: Income Status Versus Mortgage Payment

Table of HHIncome by MortgagePayment
HHIncome(Household Income)MortgagePayment(Mortgage Payment)
FrequencyRow Pct$350 and Below$351 to $1000$1001 to $1600Over $1600Total
Negative309.939732.129230.468327.48302
$0 to $45K2292916.378312559.332261716.14114368.16140107
$45K to $90K138776.9610366051.995477827.482705213.57199367
Above $90K59442.895267925.586247430.338486741.20205964
Total42780239561139961123438545740

      Output 2.2.4: Income Status Versus Mortgage Payment for Metropolitan Households (Table 1 of 3)

Table 1 of HHIncome by MortgagePayment
Controlling for Metro=Metro, Inside City
HHIncome(Household Income)MortgagePayment(Mortgage Payment)
FrequencyRow Pct$350 and Below$351 to $1000$1001 to $1600Over $1600Total
Negative00.00730.43939.13730.4323
$0 to $45K159610.75894960.30259717.50170011.4514842
$45K to $90K9104.75921548.13557129.10345018.0219146
Above $90K5042.29494722.46632128.701025646.5622028
Total301023118144981541356039

      This section reviews and extends some fundamental SAS concepts demonstrated in code supplied for Chapter 1, with these examples built upon a simplified version of the case study data. First, Program 2.3.1 uses the CONTENTS and PRINT procedures to make an initial exploration of the Ipums2005Mini data set. To begin, make sure the BookData library is assigned as done in Chapter 1.

      Program 2.3.1: Using the CONTENTS and PRINT Procedures to View Data and Attributes

      proc contents data=bookdata.ipums2005mini;

      ods select variables;

      run;

      proc print data=bookdata.ipums2005mini(obs=5);

      var state MortgageStatus MortgagePayment HomeValue Metro;

      run;

       The BookData.Ipums2005Mini data set is a modification of a data set used later in this chapter, BookData.Ipums2005Basic. It subsets the original data set down to a few records and is used for illustration of these initial concepts.

       The ODS SELECT statement limits the output of a given procedure to the chosen tables, with the Variables table from PROC CONTENTS containing the names and attributes of the variables in the chosen data set. Look back to Program 1.4.4, paying attention to the ODS TRACE statement and its results, to review how this choice is made.

       The OBS= data set option limits the number of observations processed by the procedure. It is in place here simply to limit the size of the table shown in Output 2.3.1B. At various times in this text, the output shown may be limited in scope; however, the code given may not include this option for all such cases.

       The VAR statement is used in the PRINT procedure to select the variables to be shown and the column order in which they appear.

      Output 2.3.1A: Using the CONTENTS Procedure to View Attributes

Alphabetic List of Variables and Attributes
#VariableTypeLenFormat
4CITYPOPNum8
2COUNTYFIPSNum8
10CityChar43
6HHINCOMENum8
7HomeValueNum8
3METRONum8BEST12.
5MortgagePaymentNum8
9MortgageStatusChar45
11OwnershipChar6
1SERIALNum8
8stateChar57

      Output 2.3.1B: Using the PRINT Procedure to View Data

ObsstateMortgageStatusMortgagePaymentHomeValueMETRO
1South CarolinaYes, mortgaged/ deed of trust or similar debt200325004
2North CarolinaNo, owned free and clear050001
3South CarolinaYes, mortgaged/ deed of trust or similar debt360750004
4South CarolinaYes, contract to purchase430225003
5North CarolinaYes, mortgaged/ deed of trust or similar debt450650004

      As seen in Chapter 1, SAS variable names have a certain set of restrictions they must meet, including no special characters other than an underscore. This potentially limits the quality of the display for items such as the headers in PROC PRINT. SAS does permit the assignment of labels to variables, substituting more descriptive text into the output in place of the variable name, as demonstrated in Program 2.3.2.

      Program 2.3.2: Assigning Labels

      proc print data=bookdata.ipums2005mini(obs=5) noobs label;


Скачать книгу