Here is some JSON. I omitted "number" in several entries.
[ { "type": "Full", "info" : [ { "name" : "Eric" , "age" : 21, "phone" : [ { "type" : "cell" }, { "type" : "home", "number" : "542" } ] }, { "name" : "John", "age" : 22, "phone" : [ { "type" : "cell", "number" : "456" }, { "type" : "home"}, { "type" : "home"} ] } ] }, { "type": "Part", "info" : [ { "name" : "Bjorn" , "age" : 27, "phone" : [ { "type" : "cell", "number" : "721" }, { "type" : "burner"} ] } ] } ]
Here is a map. I am reading "number" 3 times:
{ "DATASETS": [ { "DSNAME": "all", "TABLEPATH": "/root/info/phone", "VARIABLES": [ { "NAME": "Type", "TYPE": "CHARACTER", "PATH": "/root/info/phone/type" }, { "NAME": "number1", "TYPE": "CHARACTER", "PATH": "/root/info/phone/number" }, { "NAME": "number2", "TYPE": "NUMERIC", "PATH": "/root/info/phone/number", "INFORMAT": ["BEST", 3, 0] }, { "NAME": "number3", "TYPE": "NUMERIC", "PATH": "/root/info/phone/number" } ] } ] }
Here are the results.
filename jsondata "example.json";
filename example "example.map";
libname example JSON fileref=jsondata map=example;
data work.test;
set example.all;
run;
When using an informat, the results seem to be getting retained instead of appearing as missing. How do I fix this?
You might have a contact Tech Support and see if this is a defect.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.