BookmarkSubscribeRSS Feed
Sonia123
Calcite | Level 5

Safety net hospitals are defined as those hospitals that provide health care for low income and uninsured patients. We will use data from American Hospital Association to categorize hospitals in Virginia into 3 safety net categories: Safety net Hospitals, Partial safety net and Not safety net.

We received 4 data files from AHA for the years 2013 to 2016

We will categorize the Safety net status each hospital in every year. So, we need to apply the following steps in year 2013 first:

Part A.

  1. Use the data set aha2013
  2. Generate a variable year that is the year of the begin Date variable (DTBEG).    *       
  3. Generate a new variable TOTBDS= the total number of beds in the hospital. The numbers of beds by specialty are provided in the data as: (GENBD PEDBD, OBBD, MSICBD, CICBD, NICBD, NINTBD, PEDICBD, BRNBD, SPCICBD, REHABBD, ALCHBD, PSYBD, SNBD88, ICFBD88, OTHLBD94, and OTHBD94).                  *        
  4. Classify the hospital size by the total number of beds into 200 bed increments.          *
  5. Classify hospitals into Hospital if the name MNAME includes the word hospital, or Medical Center if MNAME indicates it is a center. (hint: run a tabulation (or proc freq) for the MNAME variable).                                                                            **       
  6. Generate the following variables:
    1. prcntCharity: the percent of charity defined as the net charity (NETCHARITY_IR) divided by the gross inpatient revenue (GRSINPREV_IR).*
    2. prcntMCdCharges: the percent of Medicaid charges as the inpatient revenue for Medicaid patients (GRSINPATMCD) divided by the gross inpatient revenue (GRSINPREV_IR).                                                                                         *
    3. prcntMCdDischarge: the percent of Medicaid discharges as total numbers of Medicaid admissions (ADMMCD)  divided by total numbers of admission (ADMTS).                                                                                             
  7. Calculate the state mean and standard deviation of each of the 3 new variables: prcntCharity, prcntMCdCharges, prcntMCdDischarge in Virginia in year 2013.     **

 

  1. Merge the state means and standard deviations into the aha2013 dataset                      ***

 

  1. Using arrays, determine if the hospitals: prcntCharity, prcntMCdCharges, prcntMCdDischarge are greater the 1 standard deviation above the state mean of each of those percentages.  Create new variables if needed.                                         **

 

  1. If the hospital is missing any of the 3 percentages (prcntCharity, prcntMCdCharges, prcntMCdDischarge) then safety net is not assigned.                                   *

 

  1. The hospital is defined as SN=1 if each of its 3 percentages are greater than 1 standard deviation above the state means; otherwise it is SN=2 (partial) if at least one of its 3 percentages are greater than one standard deviation above the state means, otherwise it is SN=3 (not safety net).                                                                                   ***

 

  1. Save the data as aha_SN_2013                                                                 

Part B

Write a SAS macro                                                                                  

% macro calcSN(datasetName) ;

 Perform all steps 1-12 in section A above

%mend;

2 REPLIES 2
ballardw
Super User

Please provide $200 per hour for my time. 😈

 

We are willing to help with specific problems but this request sounds a lot like "do all my work for me".

Show us what you have attempted and the problems you are having.

Be prepared to share data, the code you have attempted and problems with the code.

Just because you say "use AHA2013" does not mean we have any access to that data and there is no reason that we have to find it, you should be prepared to share at least some of it related to your questions.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against. Or write your own data step with just the variables needed.

 

 

Provide code or log text by pasting into a text box opened on the forum using the </> icon that appears above the main message window as the forum software will reformat text pasted into the main window. This means that sometimes code pasted will not run correctly. Also for log entries the text box will display diagnostic characters and messages in a more meaningful fashion for discussion.

A_Kh
Lapis Lazuli | Level 10

ChatGPT. 
Certainly! Below is a SAS code that performs the steps outlined in Part A for the year 2013. Afterward, it merges the state means and standard deviations into the aha2013 dataset and determines the safety net status for each hospital, saving the result as aha_SN_2013. The SAS macro %calcSN is also provided:

data aha2013;
  /* Your code to read in the aha2013 data file */
  set aha2013;

  /* Step 1: Generate the variable 'year' */
  year = year(dtbeg);

  /* Step 2: Generate the variable 'TOTBDS' */
  totbds = sum(genbd, pedbd, obbd, msicbd, cicbd, nicbd, nintbd, pedicbd, 
               brnbd, spcicbd, rehabbd, alchbd, psybd, snbd88, icfbd88, othlbd94, othbd94);

  /* Step 3: Classify hospital size */
  if totbds <= 200 then size = '0-200';
  else if totbds <= 400 then size = '201-400';
  else if totbds <= 600 then size = '401-600';
  else if totbds <= 800 then size = '601-800';
  else size = '801+';

  /* Step 4: Classify hospitals into Hospital or Medical Center */
  if index(upcase(mname), 'HOSPITAL') then type = 'Hospital';
  else if index(upcase(mname), 'CENTER') then type = 'Medical Center';

  /* Step 5: Generate the required variables */
  prcntCharity = netcharity_ir / grsinprev_ir;
  prcntMCdCharges = grsinpatmcd / grsinprev_ir;
  prcntMCdDischarge = admmcd / admts;

run;

/* Step 6: Calculate state mean and standard deviation */
proc means data=aha2013 mean std;
  var prcntCharity prcntMCdCharges prcntMCdDischarge;
  where state = 'VA' and year = 2013;
  output out=state_stats mean= state_mean std= state_std;
run;

/* Step 7: Merge state means and standard deviations into aha2013 */
data aha2013;
  merge aha2013 state_stats;
  by state year;
run;

/* Step 8-11: Determine safety net status */
data aha_SN_2013;
  set aha2013;

  array prcnt(*) prcntCharity prcntMCdCharges prcntMCdDischarge;
  array std(*) state_mean_prcntCharity state_mean_prcntMCdCharges state_mean_prcntMCdDischarge;
  array std_dev(*) state_std_prcntCharity state_std_prcntMCdCharges state_std_prcntMCdDischarge;

  /* Step 12: Assign safety net status */
  sn = 3; /* Default value for not safety net */
  do i = 1 to dim(prcnt);
    if prcnt[i] > (state_mean[i] + state_std[i]) then sn = 1;
    else if prcnt[i] > state_mean[i] then sn = 2;
  end;
  drop i;
run;

%macro calcSN(datasetName);
  data &datasetName;
    set &datasetName;

    /* Insert the code from Part A here */
    
  run;
%mend;

/* Example of using the macro */
%calcSN(aha2013);


This code assumes that you have loaded the AHA data into the aha2013 dataset. Adjust the dataset name and variable names as needed based on the actual structure of your data. Additionally, make sure to customize the file paths for input and output as per your system configuration.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 658 views
  • 6 likes
  • 3 in conversation