Sunday, March 19, 2023

GPT4 Does Excel: Adding CMS "Lab Test Allowed Units (YR)" and "Lab Test Allowed Charges (YR)" to CLFS

See also in Google Doc.


CMS provides extensive spreadsheets of lab data.  They regularly update the Clinical Laboratory Fee Schedule, which includes CPT code and unit price and short test name.  They have another spreadsheet called National Part B Summary Data (here) which includes CPT code,  allowed total utilization, allowed total charges, but usually no code name.

As you may have head, Chat GPT is outstanding at providing all kinds of computer instructions, including Excel code.   Merging the data sets

[Code] [Name] [Price] from one source, and [Code] [Allowed Units] [Allowed Charges] from another source, is fairly simple Excel, but not easy for me to figure out.   Chat GPT instantly provides instructions.

Here is an example.

I need help with Excel to merge identified data from one excel worksheet to another. In Worksheet 01, I have three fields which are (Numeric Identifier, Name of Product, and Unit Price). In Worksheet 02, I have three fields which are (Numeric Identifier, Total Unit Sales 2021, and Total Revenue 2021). There are about 1000 rows, correspoending to about 1000 unique "Numeric Identifiers." The rows between the worksheets do not match perfectly, since Worksheet 01 is the full set of products (each with Name and Price) while Worksheet 02 is somewhat shorter and some products had no sales and are absent from Worksheet 02. Show me how to do one of two things. One answer method would be to add Worksheet 02 "Total unit sales 2021" and "Total Revenue 2021" row by row to amplify the data seen on Worksheet 01. Another method would be to create a new Worksheet 03 which has all five fields for every row where they exist. Thank you.

To merge the data from the two worksheets based on the "Numeric Identifier" column, you can use the VLOOKUP function in Excel. I will explain both methods you've mentioned.

Method 1: Add "Total Unit Sales 2021" and "Total Revenue 2021" to Worksheet 01

  1. Open your Excel file with both worksheets.
  2. Go to Worksheet 01 and add two new column headers: "Total Unit Sales 2021" and "Total Revenue 2021."
  3. In the first cell under the "Total Unit Sales 2021" column (let's say it's D2), enter the following formula:

=IFERROR(VLOOKUP(A2, 'Worksheet 02'!$A$2:$C$1001, 2, FALSE), 0)

Replace 'Worksheet 02' with the actual name of your second worksheet if it's different. Adjust the range $A$2:$C$1001 if there are more than 1000 rows.

  1. In the first cell under the "Total Revenue 2021" column (let's say it's E2), enter the following formula:

=IFERROR(VLOOKUP(A2, 'Worksheet 02'!$A$2:$C$1001, 3, FALSE), 0)

  1. Click on the cell D2, then click the bottom-right corner of the cell and drag it down to copy the formula to all other rows.
  2. Do the same for cell E2.

Now, Worksheet 01 should have "Total Unit Sales 2021" and "Total Revenue 2021" data added to it.

Method 2: Create a new Worksheet 03 with all five fields

  1. Create a new worksheet called "Worksheet 03" in the same Excel file.
  2. Copy the headers and data from Worksheet 01 to Worksheet 03.
  3. Add two new column headers in Worksheet 03: "Total Unit Sales 2021" and "Total Revenue 2021."
  4. Follow steps 3-6 from Method 1, but this time, apply the formulas to the new worksheet (Worksheet 03).

Now, Worksheet 03 should have all five fields with data from both worksheets.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.