<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extracting multiple values having same path in json using json map in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806525#M317778</link>
    <description>&lt;P&gt;I answered this on StackOverflow (and Reddit! Hitting all of the channels!) where it seems that the original poster wants the "name" values to be proper SAS variables. Achievable using what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3480"&gt;@BillM_SAS&lt;/a&gt;&amp;nbsp;suggests, plus a transpose step:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname j json fileref=test;
proc transpose 
 data=j.content 
 out=want;
 id name;
 var value;
run;
&lt;/LI-CODE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;LI-CODE lang="shell"&gt;                  customer_    customer_
 Obs    _NAME_       ID          name

  1     value         1          John  &lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 07 Apr 2022 14:24:05 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2022-04-07T14:24:05Z</dc:date>
    <item>
      <title>Extracting multiple values having same path in json using json map in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806471#M317745</link>
      <description>&lt;P&gt;JSON&lt;/P&gt;&lt;PRE&gt;{
  "totalCount": 2,
  "facets": {},
  "content": [
    [
      {
        "name": "customer_ID",
        "value": "1"
      },
      {
        "name": "customer_name",
        "value": "John"
      }
    ]
  ]
}&lt;/PRE&gt;&lt;P&gt;How to get the values under "name" using a json map.&lt;BR /&gt;i.e i need to get the out as "customer_ID" and "customer_name" using a json map.&lt;/P&gt;&lt;P&gt;Below is my json map.&lt;/P&gt;&lt;PRE&gt;{
  "DATASETS": [
    {
      "DSNAME": "customers",
      "TABLEPATH": "/root/content",
      "VARIABLES": [
        {
          "NAME": "name",
          "TYPE": "CHARACTER",
          "PATH": "/root/content/name"
        },
        {
          "NAME": "name",
          "TYPE": "CHARACTER",
          "PATH": "/root/content/name"
        },
        {
          "NAME": "value",
          "TYPE": "CHARACTER",
          "PATH": "/root/content/value"
        },
        {
          "NAME": "value",
          "TYPE": "CHARACTER",
          "PATH": "/root/content/value"
        }
        
      ]
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;The output i am getting is only "customer_name".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 11:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806471#M317745</guid>
      <dc:creator>melligeri</dc:creator>
      <dc:date>2022-04-07T11:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple values having same path in json using json map in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806497#M317762</link>
      <description>&lt;P&gt;I just cut out the duplication in the map file that you supplied. &lt;BR /&gt;&lt;BR /&gt;Map file named ./sasuser/json.map&lt;/P&gt;
&lt;PRE&gt;{
  "DATASETS": [
    {
      "DSNAME": "customers",
      "TABLEPATH": "/root/content",
      "VARIABLES": [
        {
          "NAME": "name",
          "TYPE": "CHARACTER",
          "PATH": "/root/content/name"
        },
        {
          "NAME": "value",
          "TYPE": "CHARACTER",
          "PATH": "/root/content/value"
        }        
      ]
    }
  ]
}
&lt;/PRE&gt;
&lt;P&gt;Existing JSON file (named ./sasuser/json.sas):&lt;/P&gt;
&lt;PRE&gt;{
  "totalCount": 2,
  "facets": {},
  "content": [
    [
      {
        "name": "customer_ID",
        "value": "1"
      },
      {
        "name": "customer_name",
        "value": "John"
      }
    ]
  ]
}&lt;/PRE&gt;
&lt;P&gt;SAS code run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mapRef './sasuser/json.map';
libname x json './sasuser/json.sas' map=mapRef;
proc print data=x.customers; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;OUTPUT:&lt;/P&gt;
&lt;PRE&gt;Obs  name           value 
1    customer_ID    1 
2    customer_name  John &lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2022 13:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806497#M317762</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2022-04-07T13:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple values having same path in json using json map in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806525#M317778</link>
      <description>&lt;P&gt;I answered this on StackOverflow (and Reddit! Hitting all of the channels!) where it seems that the original poster wants the "name" values to be proper SAS variables. Achievable using what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3480"&gt;@BillM_SAS&lt;/a&gt;&amp;nbsp;suggests, plus a transpose step:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname j json fileref=test;
proc transpose 
 data=j.content 
 out=want;
 id name;
 var value;
run;
&lt;/LI-CODE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;LI-CODE lang="shell"&gt;                  customer_    customer_
 Obs    _NAME_       ID          name

  1     value         1          John  &lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-multiple-values-having-same-path-in-json-using-json/m-p/806525#M317778</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-07T14:24:05Z</dc:date>
    </item>
  </channel>
</rss>

