I have three large datasets and they have some common person ID and different variables. I want to output these three datasets to one JSON file without merging them first. Here are their structures like: (08032017 UPDATED NOTE: In the real case, I have 10,000 unique person ID for three datasets, and about 1000 different variables for each dataset, one person ID may have different numbers of claims) Data1: Person_ID claim_ID var1 var2 var3 1 ab 12 23 34 1 cc 34 54 32 2 ee 56 32 55 Data2: Person_ID claim_ID var1 var2 var3 1 gh 11 22 23 2 cd 34 67 43 3 es 29 32 90 Data3: Person_ID claim_ID var1 var2 var3 1 yu 11 22 23 3 uy 34 67 43 4 er 29 32 90 I would like to print out all three datasets by the same person_id. Like following: “person ID”: 1, [{“claim_id”:”ab”, “var1”:”12”, …}, {“claim_id”:”cc”, “var1”:”34”, …}, {“claim_id”:”gh”, “var1”:”11”, …}, {“claim_id”:”yu”, “var1”:”11”, …}], “person ID”:2, [{“claim_id”:”ee”, “var1”:”56”, …}, {“claim_id”:”cd”, “var1”:”34”, …}], … I was thinking to pull out all distinct Person_id and corresponding claim_id to a dataset, data4: person_ ID Claim_ID_1 Claim_ID_2 Claim_ID_3 Claim_ID_4 1 ab cc gh yu 2 ee 3 es uy 4 er Then use macro, %macro data1(_claim);
set data2(where=(claim_id=&_claim));
put '"person id":"' person_id '","';
…
%mend;
data _null_;
file print PS = 32767;
set data4 end=lastrec;
array xclaim $ claim_ID_1 - claim_ID_4;
do i= 1 to 4;
if xclaim[i] ne ' ' then do ;
CALL SYMPUT ('id', xclaim[i]);
%data1(&id);
%data2(&id);
%data3(&id);
end;
run; It doesn't work. Has anyone a better idea? Thanks in advanced!
... View more