<?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 Reading time series data with LIBNAME JSON in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/431964#M106907</link>
    <description>&lt;P&gt;Hey Together,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am working first time with the Option to READ JSON with the specific Libname engine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is stock markets time series, provided by &lt;A href="https://www.alphavantage.co/" target="_blank"&gt;Alphavantage&lt;/A&gt;. A sample of daily time series data with 100 records is also available &lt;A href="https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&amp;amp;symbol=MSFT&amp;amp;apikey=demo" target="_blank"&gt;here&lt;/A&gt;. The structure is following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
    "Meta Data": {
        "1. Information": "Daily Prices (open, high, low, close) and Volumes",
        "2. Symbol": "MSFT",
        "3. Last Refreshed": "2018-01-29 14:36:51",
        "4. Output Size": "Compact",
        "5. Time Zone": "US/Eastern"
    },
    "Time Series (Daily)": {
        "2018-01-29": {
            "1. open": "95.1400",
            "2. high": "95.4500",
            "3. low": "93.7600",
            "4. close": "94.0850",
            "5. volume": "19659007"
        },
        "2018-01-26": {
            "1. open": "93.1200",
            "2. high": "94.0600",
            "3. low": "92.5800",
            "4. close": "94.0600",
            "5. volume": "26348999"
        },
        "2018-01-25": {
            "1. open": "92.4650",
            "2. high": "93.2400",
            "3. low": "91.9300",
            "4. close": "92.3300",
            "5. volume": "23983094"
        }
    }
}&lt;/PRE&gt;&lt;P&gt;I've tried the code from Chris Hemedingers Post '&lt;A title="The SAS dummy" href="https://blogs.sas.com/content/sasdummy/2016/12/02/json-libname-engine-sas/" target="_blank"&gt;Reading data with the SAS JSON libname engine&lt;/A&gt;'. But the simple way doesn't shows success... It creates a data set for every day of the time series, looks not very elegant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next i tried to create a own JSON map, that's the point&amp;nbsp;where i am struggling now.&lt;BR /&gt;Here comes my try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "DATASETS": [

 {
      "DSNAME": "data",
      "TABLEPATH": "/root/Time Series (Daily)",
      "VARIABLES": [
        {
          "NAME": "date",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/date"
        },
        {
          "NAME": "open",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/date/1. open",
          "CURRENT_LENGTH": 7
        },
        {
          "NAME": "close",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/2date/4. close",
          "CURRENT_LENGTH": 7
        },
        {
          "NAME": "volume",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/date/5. volume",
          "CURRENT_LENGTH": 8
        }
      ]
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;i am using SAS University Edition with the following SAS Code (think you have to change the path to the file with the Map):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Assign filename 'resp' for the response */
 filename resp temp;

/* Query Alphavantage */
proc http
 url="https://www.alphavantage.co/query?function=TIME_SERIES_DAILY%str(&amp;amp;)symbol=MSFT%str(&amp;amp;)apikey=demo"
 method= "GET"
 out=resp;
run;
&lt;BR /&gt;/* Print a sample of JSON structure to log */
data _NULL_;
	infile resp;
	input;
	put _INFILE_;
	if _N_ gt 18 then stop;
run;
&lt;BR /&gt;/* Assigning JSON Libname engine */
libname alpha json fileref=resp map='/folders/myshortcuts/import/json_Alpha_DAILY.map';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The expanded dataset 'all' is created successfully but with no records in it....&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see what's initially wrong, maybe the JSON structure is unconventional???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does someone have a trick or suggestion???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!!!&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2018 20:49:10 GMT</pubDate>
    <dc:creator>atw78de</dc:creator>
    <dc:date>2018-01-29T20:49:10Z</dc:date>
    <item>
      <title>Reading time series data with LIBNAME JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/431964#M106907</link>
      <description>&lt;P&gt;Hey Together,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am working first time with the Option to READ JSON with the specific Libname engine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is stock markets time series, provided by &lt;A href="https://www.alphavantage.co/" target="_blank"&gt;Alphavantage&lt;/A&gt;. A sample of daily time series data with 100 records is also available &lt;A href="https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&amp;amp;symbol=MSFT&amp;amp;apikey=demo" target="_blank"&gt;here&lt;/A&gt;. The structure is following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
    "Meta Data": {
        "1. Information": "Daily Prices (open, high, low, close) and Volumes",
        "2. Symbol": "MSFT",
        "3. Last Refreshed": "2018-01-29 14:36:51",
        "4. Output Size": "Compact",
        "5. Time Zone": "US/Eastern"
    },
    "Time Series (Daily)": {
        "2018-01-29": {
            "1. open": "95.1400",
            "2. high": "95.4500",
            "3. low": "93.7600",
            "4. close": "94.0850",
            "5. volume": "19659007"
        },
        "2018-01-26": {
            "1. open": "93.1200",
            "2. high": "94.0600",
            "3. low": "92.5800",
            "4. close": "94.0600",
            "5. volume": "26348999"
        },
        "2018-01-25": {
            "1. open": "92.4650",
            "2. high": "93.2400",
            "3. low": "91.9300",
            "4. close": "92.3300",
            "5. volume": "23983094"
        }
    }
}&lt;/PRE&gt;&lt;P&gt;I've tried the code from Chris Hemedingers Post '&lt;A title="The SAS dummy" href="https://blogs.sas.com/content/sasdummy/2016/12/02/json-libname-engine-sas/" target="_blank"&gt;Reading data with the SAS JSON libname engine&lt;/A&gt;'. But the simple way doesn't shows success... It creates a data set for every day of the time series, looks not very elegant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next i tried to create a own JSON map, that's the point&amp;nbsp;where i am struggling now.&lt;BR /&gt;Here comes my try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "DATASETS": [

 {
      "DSNAME": "data",
      "TABLEPATH": "/root/Time Series (Daily)",
      "VARIABLES": [
        {
          "NAME": "date",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/date"
        },
        {
          "NAME": "open",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/date/1. open",
          "CURRENT_LENGTH": 7
        },
        {
          "NAME": "close",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/2date/4. close",
          "CURRENT_LENGTH": 7
        },
        {
          "NAME": "volume",
          "TYPE": "CHARACTER",
          "PATH": "/root/Time Series (Daily)/date/5. volume",
          "CURRENT_LENGTH": 8
        }
      ]
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;i am using SAS University Edition with the following SAS Code (think you have to change the path to the file with the Map):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Assign filename 'resp' for the response */
 filename resp temp;

/* Query Alphavantage */
proc http
 url="https://www.alphavantage.co/query?function=TIME_SERIES_DAILY%str(&amp;amp;)symbol=MSFT%str(&amp;amp;)apikey=demo"
 method= "GET"
 out=resp;
run;
&lt;BR /&gt;/* Print a sample of JSON structure to log */
data _NULL_;
	infile resp;
	input;
	put _INFILE_;
	if _N_ gt 18 then stop;
run;
&lt;BR /&gt;/* Assigning JSON Libname engine */
libname alpha json fileref=resp map='/folders/myshortcuts/import/json_Alpha_DAILY.map';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The expanded dataset 'all' is created successfully but with no records in it....&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see what's initially wrong, maybe the JSON structure is unconventional???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does someone have a trick or suggestion???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!!!&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/431964#M106907</guid>
      <dc:creator>atw78de</dc:creator>
      <dc:date>2018-01-29T20:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading time series data with LIBNAME JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/431978#M106913</link>
      <description>&lt;P&gt;It's very easy to combine data sets in SAS so maybe that's an option instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/61275"&gt;@atw78de&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;It creates a data set for every day of the time series, looks not very elegant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 21:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/431978#M106913</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T21:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading time series data with LIBNAME JSON</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/432000#M106919</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has a good point -- I often use SQL or DATA step to combine the multiple tables instead of creating a JSON map.&amp;nbsp; Since the table names will change with every series that you create, that might be the best option.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 22:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-time-series-data-with-LIBNAME-JSON/m-p/432000#M106919</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-01-29T22:51:32Z</dc:date>
    </item>
  </channel>
</rss>

