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
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.
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.
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.
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.