****************************************************************************************************************; ********************************Course 2 SAS Programs - Medicaid************************************************; ****************************************************************************************************************; ***************************************************************************************; *Course 2, Module 6, Task 1 - Create SAS formatted Feasibility File; ***************************************************************************************; /*******************************************************************/ * filename statement specifies local location to which * * NHANES Feasibility .DAT data set was copied * * libname statements specifies local location of permanent * * SAS data set to be created * /*******************************************************************/; * Log/List Options *; options ls=120 ps=42 missing=' ' nocenter validvarname=upcase compress=binary; * Output SAS Library *; libname NHANES "C:\NHANES\"; * <-- Place Output Library Path Here *; * Input File Reference *; filename intext "\\...\MCARE_FEAS_NHANES_2011_2012.DAT"; data nhanes.nhanes_11_12_elig_Medicaid; infile intext lrecl=60 ; input @ 1 SEQN 5. @15 CMS_MEDICAID_MATCH 1. ; * Labels *; label SEQN = 'NHANES SEQN' CMS_MEDICAID_MATCH = 'CMS Medicaid Match Status' ; * Keep *; keep SEQN CMS_MEDICAID_MATCH ; run; title 'NHANES 2011-2012 Feasibility Data'; proc contents data=nhanes.nhanes_11_12_elig_Medicaid varnum; run; proc print data=nhanes.nhanes_11_12_elig_Medicaid (obs=10); title2 'Sample Listing - 10 Rows'; run; proc means data=nhanes.nhanes_11_12_elig_Medicaid; title2 'Simple Means'; run; ***************************************************************************************; *Course 2, Module 6, Task 2 - Extract and Copy NHANES Data Files to Permanent Libraries; ***************************************************************************************; * This program will output data to the SAS library created in Task 1: libname NHANES "C:\NHANES\"; libname XP xport "\\...\demo_g.xpt"; proc copy in=XP out=NHANES; run; ***************************************************************************************; *Course 2, Module 7, Task 1 - Merge Datasets; ***************************************************************************************; * This program will output the merged data to the SAS library created in Task 1: libname NHANES "C:\NHANES\"; data temp; set nhanes.nhanes_11_12_elig_Medicaid; run; proc sort data=temp; by SEQN; run; proc sort data=nhanes.demo_g; by SEQN; run; data nhanes.merg1112_Medicaid; merge temp nhanes.demo_g; by SEQN; /*Regroup race_ethnicity as 4 categories*/ if ridreth3=3 then raceth=1; /*Non-Hispanic White*/ else if ridreth3=4 then raceth=2; /*Non-Hispanic Black*/ else if ridreth3 in (1,2) then raceth=3; /*Mexican American/Other Hispanic*/ else raceth=4; /*Other*/ label raceth = 'Race/ethnicity (recode)'; run; title 'Merged NHANES Feasibility/Demographic Data'; proc contents data=nhanes.merg1112_Medicaid varnum; run; proc print data=nhanes.merg1112_Medicaid (obs=10); title2 'Sample Listing - 10 Rows of select variables'; var seqn cms_medicaid_match riagendr ridreth3 raceth wtmec2yr; run; proc means data=nhanes.merg1112_Medicaid; title2 'Simple Means'; var seqn CMS_MEDICAID_MATCH; run; ***************************************************************************************; *Course 2, Module 8, Task 1 - Produce Table of Race/ethnicity and Gender by Linkage Eligibility and Match Status of NHANES Respondents; ***************************************************************************************; * This program will read data from the SAS library created in Task 1: libname NHANES "C:\NHANES\"; proc format; value CMSMATCH 1 = 'Linked' 2 = 'Not Linked' 3 = 'Linked - Child' 9 = 'Ineligible'; value GENDER 1 = 'Male' 2 = 'Female'; value RACE_ONE 1 = 'non-Hispanic white' 2 = 'non-Hispanic black' 3 = 'Mexican American/Other Hispanic' 4 = 'Other'; run; title 'Merged NHANES 2011-2012 Feasibility/Demographic Data'; proc tabulate data=nhanes.merg1112_Medicaid format=BEST10.0; class RACETH / order=unformatted missing; class RIAGENDR / order=unformatted missing; class CMS_MEDICAID_MATCH / order=formatted missing; table N="Total" (RIAGENDR RACETH)*N=' ' , /* Row Dimensions */ CMS_MEDICAID_MATCH=' ' /* Column Dimension */ /ROW=FLOAT; format CMS_MEDICAID_MATCH cmsmatch. RIAGENDR gender. RACETH race_one.; title2 'Frequency Distribution of Gender and Race/ethnicity by Medicaid Match Status'; run; 国产精品久久久久久一级毛片