I have JSON where the values have a forward slash in them such as "Amt w/total"
{
"data" : [
{ "a" : 1 , "Amt w/total" : 10 },
]
}So when the map is created it looks like
{
"NAME": "Amt_w_total",
"TYPE": "NUMERIC",
"PATH": "/root/data/Amt w/total"
}This reads in as all missing because I assume it's treating the / as a separator in the path and looking for values of "Amt w" and "total".
Is there any way to tell it the slash is part of the value?
Just a long shot:
Maybe SAS expects the / to be escaped, as in
Amt w\/total
and gets confused?
Does the map work if you correct the map?
Ask SAS support for help.
It is definitely valid to have / in key value.
You can try it yourself:
https://www.w3schools.com/js/tryit.asp?filename=tryjson_object_loop
Not sure where to look for what is valid in that path syntax that the map files are using.
If you cannot get it to work then perhaps your can made a modified version of the data that changes that value. Perhaps using unix tool like sed or even just reading the file in a datastep and using TRANWRD().
filename json temp;
options parmcards=json;
parcards4;
{
"data" : [
{ "a" : 1 , "Amt w/total" : 10 }
]
}
;;;;
filename fixed temp;
data _null_;
infile json;
file fixed;
input;
_infile_=tranwrd(_infile_,'"Amt w/total"','"Amt w_total"');
run;
filename map temp;
libname json json map=map automap=reuse;
proc print data=json.data;
run;
ordinal_ ordinal_ Amt_w_ Obs root data a total 1 1 1 1 10
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.