BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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;


/**************************************************/
array trevcds(*) $ i_REVENUE_CODE1-i_REVENUE_CODE20;
array trevchg(*) i_SUBMITTED_CHARGES_REV1-i_SUBMITTED_CHARGES_REV20;

REVCD = '';


IF i_REVENUE_CODE1 NE '' THEN DO;

do i=1 to dim(trevcds);

if trevcds(i) ne "" then do;

REVCD = trevcds(i);

totchg=put(trevchg(i),12.2);



OUTPUT libmedc.trs_test;
end;
end;
end;



else output libmedc.trs_test;
run;
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

Scott Barry
SBBWorks, Inc.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 637 views
  • 0 likes
  • 2 in conversation