BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

I have the following queries:

 

PROC SQL;
  CREATE TABLE GROUP_SAVINGS_Prep AS
  SELECT t1.COMPOUNDCODE,
         t1.NETWORK,
         t1.FilledMonth,
		 t1.MACSavingsGrouping AS Channel,
		 t1.BRAND_GENERIC,
		 t1.EXCLUSIONS,
		 t1.GroupPlanCode,
		 t1.MAC_Flag,
		 t1.Specialty_Flag,
		 t1.SERVICEPROVIDERID,
		 t1.SUM_OF_RX,
		 t1.SUM_OF_AWP,
		 t1.ApprovedIngredientCost,
		 t1.ApprovedDispensingFeeAmount
  FROM EGTASK.All_Combined_Table t1
  WHERE t1.Specialty_Flag = 'Non-Specialty' AND t1.COMPOUNDCODE ne '2' AND t1.MACSavingsGrouping ne 'MAIL' AND t1.EXCLUSIONS = 'NA'
        AND t1.GroupPlanCode IN('NEC7729','NEC7621','NEC7620');
QUIT;

PROC SQL;
CREATE TABLE GROUP_SAVINGS_PREP2 AS
SELECT t1.COMPOUNDCODE,
       t1.NETWORK,
       t1.FilledMonth,
       t1.Channel,
       t1.BRAND_GENERIC,
       t1.EXCLUSIONS,
       t1.GroupPlanCode,
       t1.MAC_Flag,
       t1.Specialty_Flag,
       t1.SERVICEPROVIDERID,
       t1.SUM_OF_RX,
       t1.SUM_OF_AWP,
       t1.ApprovedIngredientCost,
       t1.ApprovedDispensingFeeAmount,
	   t2.Brand_Discount,
	   t2.Brand_Dispense_Fee,
	   t2.Generic_Discount,
	   t2.Generic_Dispense_Fee
FROM WORK.GROUP_SAVINGS_Prep t1
INNER JOIN EGTASK.'PTSLCT _ 2016_06_17_0000'n t2 ON (input(t1.SERVICEPROVIDERID,15.) = t2.NCPDP);
QUIT;

PROC SQL;
CREATE TABLE GROUP_SAVINGS AS
SELECT t1.Brand_Dispense_Fee,
       t1.COMPOUNDCODE,
       t1.NETWORK,
       t1.FilledMonth,
       t1.Channel,
       t1.BRAND_GENERIC,
       t1.EXCLUSIONS,
       t1.GroupPlanCode,
       t1.MAC_Flag,
       t1.Specialty_Flag,
       t1.SERVICEPROVIDERID,
       t1.SUM_OF_RX,
       t1.SUM_OF_AWP,
       t1.ApprovedIngredientCost,
       t1.ApprovedDispensingFeeAmount,
	   /* New AWP Rate field */
	   (CASE
	      WHEN t1.Channel = 'Retail' and t1.BRAND_GENERIC = 'Brand' and t1.MAC_Flag = 'AWP' then t1.Brand_Discount
		  WHEN t1.Channel = 'ESN' and t1.Brand_Generic = 'Brand' and t1.MAC_Flag= 'AWP' then '.1897'
		  WHEN t1.Channel = 'Retail' and t1.Brand_Generic = 'Generic' and t1.MAC_Flag= 'NON-MAC' then t1.Generic_Discount
		  WHEN t1.Channel = 'ESN' and t1.Brand_Generic = 'Generic' and t1.MAC_Flag= 'NON-MAC' then '.3'
          ELSE (t1.SUM_OF_AWP - t1.ApprovedIngredientCost)/t1.SUM_OF_AWP
	    END) AS AWP_RATE_NEW, 
       /* New Dispensing Fee field */
	   (CASE
	      WHEN t1.CHannel = 'Retail' and t1.Brand_Generic = 'Brand' and t1.MAC_Flag= 'AWP' then t1.Brand_Dispense_Fee
		  WHEN t1.CHannel = 'ESN' and t1.Brand_Generic = 'Brand' and t1.MAC_Flag= 'AWP' then '0'
          WHEN t1.CHannel = 'Retail' and t1.Brand_Generic = 'Generic' and t1.MAC_Flag= 'NON-MAC' then t1.Generic_Dispense_Fee
		  WHEN t1.CHannel = 'ESN' and t1.Brand_Generic = 'Generic' and t1.MAC_Flag= 'NON-MAC' then '0'
		  ELSE t1.ApprovedDispensingFeeAmount/SUM_OF_RX
		END) AS DISP_FEE_NEW
FROM GROUP_SAVINGS_PREP2 t1;
QUIT;

When it hits the third query, I get an error: "Result of WHEN clause 2 is not the same data type as the preceding results." Is this something that can be solved using an input function? Or some other way to make the data types the same? I've attached a screenshot of the proc contents of the input data.

 

Thanks in advance,

JediApprentice


ProcContents.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Fields such as Brand_discount are numeric and quoted numbers such as '.1897' are character. Remove the quotes to make all alternatives the same type.

PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

Fields such as Brand_discount are numeric and quoted numbers such as '.1897' are character. Remove the quotes to make all alternatives the same type.

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1379 views
  • 0 likes
  • 2 in conversation