PerlIsGood
Programmer
Ok, I'm just starting to pick up SAS for my employer and I have my first project I'm trying to sort out. I'm pulling data from a database where the field is a 10-bit code (i.e., 0010000000). Each bit set stands for a different error code (i.e., previous example stands for a P1 error).
Writing code to catch that and place human-readable values in a field is easy, what's killin' me is figuring out how to capure a field that has multiple bits set (i.e. 1000100100). This is what I have so far:
This 'almost' works. At "PE_CODE = PHV || PBIT(i)", it only stores the value from the final loop iteration. I'm assuming that the loop is destroying the PHV (placeholder) variable at every iteration. I thought using VB-esque syntax would fix it, "PE_CODE = PE_CODE || PBIT(i)", but then my PE_CODE variable is blank...
The desired end result is to have multiple values (P1, P2, etc.) 'pushed' into the PE_CODE variable for any field that had multiple bits set.
Any ideas?
Notorious P.I.G.
Writing code to catch that and place human-readable values in a field is easy, what's killin' me is figuring out how to capure a field that has multiple bits set (i.e. 1000100100). This is what I have so far:
Code:
data test (drop=PBIT1 PBIT2 PBIT3 PBIT4 PBIT5 PBIT6 PBIT7 PBIT8 PBIT9 PBIT10 i);
set PaymentErrors;
length PE_CODE $ 20.;
array PBIT (10) $ ('P8' 'No Errors' 'P1' 'P2' 'P3' 'P4' 'P5' 'P6' 'P7' 'P9');
do i = 1 to 10;
if substr(PROCESSING_ERRORS,i,1) = 1 then PE_CODE = PVH || PBIT(i);
end;
run;
This 'almost' works. At "PE_CODE = PHV || PBIT(i)", it only stores the value from the final loop iteration. I'm assuming that the loop is destroying the PHV (placeholder) variable at every iteration. I thought using VB-esque syntax would fix it, "PE_CODE = PE_CODE || PBIT(i)", but then my PE_CODE variable is blank...
The desired end result is to have multiple values (P1, P2, etc.) 'pushed' into the PE_CODE variable for any field that had multiple bits set.
Any ideas?
Notorious P.I.G.