Hello, I want to create an xml file from a SAS table with a hierarchy. The table has the following 10 fields: currencyid, value, id, withdrawaldate, withdrawaltime, bankcode, bankbranchcode, monthreport, cuerrentdate, factorcode. Example table: bankcode bankbranchcode id withdrawaldate withdrawaltime currencyid monthreport cuerrentdate factorcode value 20 401 12332324 2020-09-12 12:20:24 00 2021-10 2021-11-01 20 400 20 490 12342 2020-09-13 12:08:00 00 2021-10 2021-11-01 20 500 This is the code I wrote: data _null_;
set work.report end=eof;
file "&outfile./Report.xml" noprint encoding="utf-8";
by id;
if _n_ =1 then
do;
put '<?xml version="1.0" encoding="utf-8"?>';
put '<ATMstockReport>';
put '<currentDate>' currentDate '</currentDate>';
put '<factorCode>' factorCode '</factorCode>';
put '<monthReport>' monthReport '</monthReport>';
put '<atmsStock>';
end;
if first.id then
do;
put '<action atmId="'id'">';
put '<bankCode>' bankCode '</bankCode>';
put '<bankBranchCode>' bankBranchCode '</bankBranchCode>';
put '<withdrawaldate>' withdrawaldate '</withdrawaldate>';
put '<withdrawaltime>' withdrawaltime '</withdrawaltime>';
put '<currencyvalue>';
end;
put '<currency dt=" 'currencyid' ">';
put '<value>' value '</value>';
put '</currency>';
if last.id then
do;
put '</currencyvalue>';
put '</action>';
end;
if eofl then
do;
put '</atmsStock>';
put '</ATMstockReport>';
end;
run; After running I get only the first record, something with the sorting of the "currencyid" field is incorrect I think. Do I need to sort the table before in a certain order? Thanks.
... View more