The following code first determines how many Brand Name drugs have just one HCPCS Code and then uses that list to pull Code, Brand Name and Generic name for those drugs from the same data source. However, is there a way to combine this into one query, perhaps with the first query as a subquery in the second? proc sql; Create Table Step2a as select Brand_name, count(*) as Cnt from Spend_util Group by Brand_Name having Count(distinct HCPCS) = 1; Create Table Step2b as select a.HCPCS label='HCPCS Code', a.Brand_name, a.Generic_Name from Spend_util as a, Step2a as b where a.Brand_name=b.Brand_name; quit;
... View more