Thanks in advance for reviewing this potentially straightforward solution. I did do a search before posting.
Question: How would I go about using SQL to create a table that lists the highest paid codes first, but then the corresponding Denied amounts for the table directly after that corresponding code.
data have;
input status code $ PaidAmount : dollar.;
format PaidAmount dollar.;
cards;
Paid 81511 $1000
Paid 81317 $500
Paid 81400 $300
Paid 81511 $2000
Denied 81511 $0 Denied 81317 $0 ;
run;
The table I would be looking to create from the data is:
Code Status PaidAmount
81511 Paid $3000
81511 Denied $0
81317 Paid $500
81317 Denied $0
81400 Paid $300
I can create a table that lists each of the variables in priority order, but not conditionally. For example, the following code only gets me to the highest paid amounts, but then the denied lines are printed out after. I would like the denied lines to come after the corresponding code's paid line, but based on the highest paid codes.
proc sql;
select code, status, paidamount format=dollar24.2
from have
group by code, status
order by paidamount ;
quit;
Thanks again!
... View more