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

I'm attempting to create two new fields in SAS based on info in an Excel sheet:

 

Within the SAS data, whenever the SERVICEPROVIDERID (in SAS) equals the NCPDP (in Excel) do the following:

 

1) Create new AWP Rate field:

 

(CASE

WHEN t1.CHannel = 'Retail' and t1.Brand_Generic = 'Brand' and t1.MAC_Flag= 'AWP' then (bring in brand rate field from excel)
WHEN t1.CHannel = 'Retail' and t1.Brand_Generic = 'Generic' and t1.MAC_Flag= 'NON-MAC' then (bring in generic rate field from excel)

END) AS New_AWP_Rate

 

2) Create new Dispensing Fee field:

 

(CASE
WHEN t1.CHannel = 'Retail' and t1.Brand_Generic = 'Brand' and t1.MAC_Flag= 'AWP' then (bring in brand dispensing fee field from excel)
WHEN t1.CHannel = 'Retail' and t1.Brand_Generic = 'Generic' and t1.MAC_Flag= 'NON-MAC' then (bring in generic dispensing fee field from excel)

END) AS NewDispensingFee

 

The bolded sentences are ones I don't understand how to implement in SAS. I am using SAS EG so I am able to import the excel sheet using the wizard and get it in to a SAS data set.

 

Thanks,

JediApprentice

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Since you don't show the structure of the Excel file(s), it's hard to give exact advice-

Either way, you need to get the Excel data accessible from SAS, with a Libname Excel, or proc import, to name two ways.

Then in your SQL, you could probably do some kind of correlated subquery.

But that code is a bit awkward, so I think if your Excel data have right attributes, a join operation would be a simpler task.

Data never sleeps

View solution in original post

1 REPLY 1
LinusH
Tourmaline | Level 20

Since you don't show the structure of the Excel file(s), it's hard to give exact advice-

Either way, you need to get the Excel data accessible from SAS, with a Libname Excel, or proc import, to name two ways.

Then in your SQL, you could probably do some kind of correlated subquery.

But that code is a bit awkward, so I think if your Excel data have right attributes, a join operation would be a simpler task.

Data never sleeps

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 995 views
  • 0 likes
  • 2 in conversation