BookmarkSubscribeRSS Feed
John2020
Calcite | Level 5

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:

 

  • As character
  • As numeric with an informat
  • As numeric without an informat

 

{
      "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;

 

image.png

When using an informat, the results seem to be getting retained instead of appearing as missing. How do I fix this?

 

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

You might have a contact Tech Support and see if this is a defect.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 626 views
  • 1 like
  • 2 in conversation