Here is my code: proc sort data = work.Calculated_Data2;
by AffiliationID ApprovedPriceType BRAND_GENERIC CarrierID ClaimOriginationFlag
ClaimStatus CLIENT CostTypeCode DISPENSEASWRITTENDAWPRODUCTSELE
ExtendedSupplyNetworkIndicator FilledMonth FilledQuarter FinalPlanCode GPINumber
MailOrderIndicator MultiSourceCode PlanDrugStatus PriceScheduleDefinition RxNetworkID
SERVICEPROVIDERID SuperPharmacyNetworkID PHARMACYZIPCODE Specialty_Flag EXCLUSIONS
IVLIndicator;
run;
data Calculated_Data3;
format Discount_HCSC Discount_AL Discount_FL Discount_Medd
Discount_MN Discount_NC Discount_Prime Discount_Horizon Percent8.4;
length Client_Specialty_Flag $30;
if _N_ = 1 then do;
declare Hash S (dataset:"egtask.SPECIALTY_LIST");
S.definekey("ProductServiceID");
S.definedata("Discount_HCSC");
S.definedata("Discount_AL");
S.definedata("Discount_FL");
S.definedata("Discount_MEDD");
S.definedata("Discount_MN");
S.definedata("Discount_NC");
S.definedata("Discount_Prime");
S.definedata("Discount_Horizon");
S.definedone();
end;
set Calculated_Data2;
if S.find() = 0 then do;
Discount_HCSC=Discount_HCSC;
Discount_AL=Discount_AL;
Discount_FL=Discount_FL;
Discount_Horizon=Discount_Horizon;
Discount_Prime=Discount_Prime;
Discount_MN=Discount_MN;
Discount_NC=Discount_NC;
Discount_MEDD=Discount_MEDD;
end;
if CLIENT in("IL","NM","OK","TX","MT","NM") and Discount_HCSC ne . then Client_Specialty_Flag = "Specialty";
else if CLIENT in("KS","ND","NE","WY") and Discount_Prime ne . then Client_Specialty_Flag = "Specialty";
else if CLIENT = "MN" and Discount_MN ne . then Client_Specialty_Flag = "Specialty";
else if CLIENT = "AL" and Discount_AL ne . then Client_Specialty_Flag = "Specialty";
else if CLIENT = "FL" and Discount_FL ne . then Client_Specialty_Flag = "Specialty";
else if CLIENT = "NJ" and Discount_Horizon ne . then Client_Specialty_Flag = "Specialty";
else if CLIENT = "NC" and Discount_NC ne . then Client_Specialty_Flag = "Specialty";
else Client_Specialty_Flag = "Non-Specialty";
run;
data EGTASK.Data_Put_In_Access;
set work.Calculated_Data3;
format AffiliationID $6. ApprovedPriceType $10. CarrierID $9. ClaimOriginationFlag $1.
ClaimStatus $1. CostTypeCode $10. DISPENSEASWRITTENDAWPRODUCTSELE $1.
ExtendedSupplyNetworkIndicator $1. FilledMonth $7. FilledQuarter $6.
GPINumber $14. MailOrderIndicator $1. MultiSourceCode $1. PlanDrugStatus $1.
PriceScheduleDefinition $10. RxNetworkID $6. RxNetworkID_CHAIN $6.
SERVICEPROVIDERID $15. SuperPharmacyNetworkID $6. PHARMACYZIPCODE $10.
SUM_of_ApprovedIngredientCost DOLLAR16.2 SUM_of_ApprDispFeeAmount DOLLAR16.2 SUM_of_QUANTITYDISPENSED 13.3 ZIP $10.;
RxNetworkID_CHAIN = RxNetworkID;
SUM_of_ApprovedIngredientCost = sum(ApprovedIngredientCost);
SUM_of_ApprDispFeeAmount = sum(ApprovedDispensingFeeAmount);
SUM_of_AWP = sum(AWP);
SUM_of_RX = sum(RX);
SUM_of_QUANTITYDISPENSED = sum(QUANTITYDISPENSED);
SUM_of_MEMBERID = sum(MemberID);
ZIP = PHARMACYZIPCODE;
by AffiliationID ApprovedPriceType BRAND_GENERIC CarrierID ClaimOriginationFlag
ClaimStatus CLIENT CostTypeCode DISPENSEASWRITTENDAWPRODUCTSELE
ExtendedSupplyNetworkIndicator FilledMonth FilledQuarter FinalPlanCode GPINumber
MailOrderIndicator MultiSourceCode PlanDrugStatus PriceScheduleDefinition RxNetworkID
SERVICEPROVIDERID SuperPharmacyNetworkID PHARMACYZIPCODE Specialty_Flag Client_Specialty_Flag EXCLUSIONS
IVLIndicator;
run; The error occurs when I get to the last datastep (in the by). It give me the error: "Variables are not properly sorted in dataset WORK.Calculated_Data3". The weird thing is, earlier on in the project, Calculated_Data2 is created with a subsetting condition based on a range of dates. When I run it for one month, it runs through this code and works with no errors. But when I run it for 4 months, it throws the error. What could be going on here?
... View more