Help! I am having trouble with this array. It is creating an additional row for every i_revenue_code. But It is making some values of the variable totchg . and thus the total sum of that variable is less than what it should be. I've tried some if/then/else statements, but it's not working.
data libmedc.trs_test ;
set libmedc.highmcdetrsmedc ( keep=clmno mbrno bill_date totchg revcd i_REVENUE_CODE1-i_REVENUE_CODE20 i_TOTAL_SUBMITTED_CHARGES i_SUBMITTED_CHARGES_REV1-i_SUBMITTED_CHARGES_REV20 );
format totchg totchg1 dollar15.2;
Having your SAS log pasted in your post will be much better for helping you diagnose your challenge. Also, you will stand to benefit by adding statements (you increment "nnn" for each command for identification in your program execution):
PUTLOG '>DIAG-nnn>' / _ALL_;
You are treating REVCD as a char variable - do you have a LENGTH associated (not FORMAT)? Same for TOTCHG - you are using a PUT which assigns a CHAR type variable -is that what you want?
So, you appear to be doing an OUTPUT, even if the variable i_REVENUE_CODE1 is blank - have you done a FREQ on this variable to see what values exist and to ensure all obs are populated? Same question posed for variable i_REVENUE_CODE2 through i_REVENUE_CODE20 which will help debug your MISSING VALUE condition for TOTCHG.
There is no KEEP (or conversely a DROP) statement in your OUTPUT file - you should have all variables available in a PROC PRINT (or PROC FREQ) against the entire output file, again to help with determining the cause.
Suggest you select one or two obs, rerun your program, and then re-post a reply with the SAS log pasted in the reply, however after some PUTLOG commands to debug the code-path and what occurs with each type of input observation.