<?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: Parsing a string variable in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157460#M2786</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks like JSON to me. If so then a Google search using something like "site:support.sas.com JSON" will return quite a few relevant links like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/296-2013.pdf" title="http://support.sas.com/resources/papers/proceedings13/296-2013.pdf"&gt;http://support.sas.com/resources/papers/proceedings13/296-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/342-2013.pdf" title="http://support.sas.com/resources/papers/proceedings13/342-2013.pdf"&gt;http://support.sas.com/resources/papers/proceedings13/342-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jun 2014 22:18:02 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-06-26T22:18:02Z</dc:date>
    <item>
      <title>Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157459#M2785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking to parse a string variable and extract several variables from the information contained in it. Listed below is an example of the string data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variable_data&lt;/P&gt;&lt;P&gt;{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the output data set with additional variables parsed from the string (shown below with variable names on top):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calories&amp;nbsp; Steps&amp;nbsp; Distance&amp;nbsp; Floors&amp;nbsp; Elevation&amp;nbsp; activeScore&lt;/P&gt;&lt;P&gt;153&amp;nbsp; 87&amp;nbsp; 0.0578725741524&amp;nbsp; 0&amp;nbsp; 0&amp;nbsp; -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a second layer of data management to this. In some cases there are two data points in one row for the string variable (example shown below)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}, {"calories":"159","steps":"77","distance":"0.0498723741524","floors":"0","elevation":"0","activeScore":"-1"}]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to parse the data as two separate rows in this case?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pronabesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 18:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157459#M2785</guid>
      <dc:creator>pronabesh</dc:creator>
      <dc:date>2014-06-26T18:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157460#M2786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks like JSON to me. If so then a Google search using something like "site:support.sas.com JSON" will return quite a few relevant links like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/296-2013.pdf" title="http://support.sas.com/resources/papers/proceedings13/296-2013.pdf"&gt;http://support.sas.com/resources/papers/proceedings13/296-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/342-2013.pdf" title="http://support.sas.com/resources/papers/proceedings13/342-2013.pdf"&gt;http://support.sas.com/resources/papers/proceedings13/342-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 22:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157460#M2786</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-06-26T22:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157461#M2787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may get you started,&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;dlm&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'}]'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; var : $ &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;150.&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;not&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing (var);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; v&amp;nbsp; calories steps distance floors elevation activeScore;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; distance &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;best32.20&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;over&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; v;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v=prxchange(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'s/.+'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;||vname(v)||&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'":"(-\d+|\d+|\d\.\d+)".*/$1/i'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;,-&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;,var);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; var;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;{"calories":"152","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;[{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}, {"calories":"159","steps":"77","distance":"0.0498723741524","floors":"0","elevation":"0","activeScore":"-1"}]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;Haikuo&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 03:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157461#M2787</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-06-27T03:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157462#M2788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile cards truncover dlm=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _infile_=compress(_infile_,'-.,','kd');&lt;/P&gt;&lt;P&gt;&amp;nbsp; input calories steps distance floors elevation activeScore;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;[{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}&lt;/P&gt;&lt;P&gt;{"calories":"159","steps":"77","distance":"0.0498723741524","floors":"0","elevation":"0","activeScore":"-1"}]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 11:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157462#M2788</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-06-27T11:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157463#M2789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your JSON file contains JSON &lt;STRONG&gt;ARRAY&lt;/STRONG&gt;, that would make problem more complicated . My suggest is like Patrick to use&lt;STRONG&gt; proc json&lt;/STRONG&gt; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 12:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157463#M2789</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-06-27T12:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157464#M2790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe PROC JSON is only for writing a SAS data set to a JSON file. You will need a SAS data step for reading a JSON file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 01:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157464#M2790</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-06-28T01:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157465#M2791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the data structure in the JSON file is orthogonal and you will always get all key:value pairs then you could try something like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data testdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines truncover dsd dlm=',}' COLUMN=point_pos;&lt;/P&gt;&lt;P&gt;&amp;nbsp; point_pos=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; row_id=_n_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while(point_pos+10 &amp;lt; lengthn(_infile_));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @point_pos&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"calories":' calories :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"steps":' steps :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"distance":' distance :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"floors":' floors :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"elevation":' elevation :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"activeScore":' activeScore :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}&lt;/P&gt;&lt;P&gt;[{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}, {"calories":"159","steps":"77","distance":"0.0498723741524","floors":"0","elevation":"0","activeScore":"-1"}]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 02:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157465#M2791</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-06-28T02:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157466#M2792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh,&lt;A class="j-reply-rte" style="font-weight: bold; font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #0e66ba; background-color: #ffffff;"&gt;Patrick&lt;/A&gt; That is disappoint about SAS for not adding such function in proc json .&lt;/P&gt;&lt;P&gt;If there were no JSON Object ,that would be easy, but considering about json object that would make problem complicated . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 12:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157466#M2792</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-06-28T12:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157467#M2793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Patrick and Ksharp. As you guys pointed out, proc JSON is only for exporting SAS files to JSON. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Patrick: Your code works if I use the datalines options. However, I have a very large datafile in which the json object is just one variable. There are other variables linked to the json object via unique identifier (example shown below). Is there a way to parse it in this case?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Print: Data Set WORK.DEVICE"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;&lt;TD class="r data"&gt;9999&lt;/TD&gt;&lt;TD class="l data"&gt;{"calories":"1736","steps":"4024","distance":"1.79278637687032","floors":"0","elevation":"0","activeScore":"-1"}&lt;/TD&gt;&lt;TD class="l data"&gt;activity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;5&lt;/TH&gt;&lt;TD class="r data"&gt;1111&lt;/TD&gt;&lt;TD class="l data"&gt;{"calories":"1583","steps":"85","distance":"0.0378725741524","floors":"0","elevation":"0","activeScore":"-1"}&lt;/TD&gt;&lt;TD class="l data"&gt;activity&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 00:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157467#M2793</guid>
      <dc:creator>pronabesh</dc:creator>
      <dc:date>2014-07-01T00:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157468#M2794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the variables are&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;obs id data activity&lt;/P&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Print: Data Set WORK.DEVICE"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;&lt;TD class="r data"&gt;9999&lt;/TD&gt;&lt;TD class="l data"&gt;{"calories":"1736","steps":"4024","distance":"1.79278637687032","floors":"0","elevation":"0","activeScore":"-1"}&lt;/TD&gt;&lt;TD class="l data"&gt;activity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;5&lt;/TH&gt;&lt;TD class="r data"&gt;1111&lt;/TD&gt;&lt;TD class="l data"&gt;{"calories":"1583","steps":"85","distance":"0.0378725741524","floors":"0","elevation":"0","activeScore":"-1"}&lt;/TD&gt;&lt;TD class="l data"&gt;activity&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 00:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157468#M2794</guid>
      <dc:creator>pronabesh</dc:creator>
      <dc:date>2014-07-01T00:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157469#M2795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way to go:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data testdata(drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines truncover dlm='"[{,}]' COLUMN=point_pos;&lt;/P&gt;&lt;P&gt;&amp;nbsp; point_pos=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; attrib &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id data informat=32. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; activity informat=$20.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input _lead_str :$30. @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if not missing(_lead_str) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=input(scan(_lead_str,1,' '),32.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data=input(scan(_lead_str,2,' '),32.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; activity=scan(_infile_,-1,'}] ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; row_id=_n_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while(point_pos+20 &amp;lt; lengthn(_infile_));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @point_pos&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"calories":' calories :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"steps":' steps :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"distance":' distance :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"floors":' floors :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"elevation":' elevation :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @'"activeScore":' activeScore :32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;4 999 {"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"} activity&lt;/P&gt;&lt;P&gt;5 1111 [{"calories":"153","steps":"87","distance":"0.0578725741524","floors":"0","elevation":"0","activeScore":"-1"}, {"calories":"159","steps":"77","distance":"0.0498723741524","floors":"0","elevation":"0","activeScore":"-1"}] activity&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 03:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157469#M2795</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-07-01T03:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157470#M2796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Just stumbled over this link &lt;A href="http://blogs.sas.com/content/sascom/2013/12/12/how-to-import-twitter-tweets-in-sas-data-step-using-oauth-2-authentication-style/" title="http://blogs.sas.com/content/sascom/2013/12/12/how-to-import-twitter-tweets-in-sas-data-step-using-oauth-2-authentication-style/"&gt; How to import Twitter tweets in SAS DATA Step using OAuth 2 authentication style - SAS Voices&lt;/A&gt; and thought this might interest you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Jul 2014 02:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157470#M2796</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-07-05T02:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157471#M2797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;Sorry . Firstly, I can't enter Twitter url , Chinese Government have already block them all . Secondly, I totally have no idea about it , OAuth 2 is a completely different thing other than general url , Maybe you should check SAS documentation detail like proc http or something else , or talk some SAS guys to see if SAS has already support this kind of connection .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OH, I know what do you mean. &lt;STRONG&gt;proc groovy&lt;/STRONG&gt; can import JSON file . That will be nice . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Jul 2014 09:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157471#M2797</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-07-06T09:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157472#M2798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was actually trying to avoid the datalines option because the file was very large. The following infile and input statement code worked. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename a "C:\Users\Pronabesh\Desktop\PLM_Stats\Biogen Devices\Data analysis\test.txt"; *This is any file, you just need something with a row or two in it;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;infile a dlm=', "';&lt;/P&gt;&lt;P&gt;input @@;&lt;/P&gt;&lt;P&gt;_infile_=data;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;@'"calories":' calories $&lt;/P&gt;&lt;P&gt;@'"steps":' steps $&lt;/P&gt;&lt;P&gt;@'"distance":' distance $;&lt;/P&gt;&lt;P&gt;put calories= steps= distance=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jul 2014 18:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Parsing-a-string-variable/m-p/157472#M2798</guid>
      <dc:creator>pronabesh</dc:creator>
      <dc:date>2014-07-11T18:03:31Z</dc:date>
    </item>
  </channel>
</rss>

