<?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 read daily json datafiles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692158#M210791</link>
    <description>&lt;P&gt;I need to read daily supplied json files on a dynamic way eg. name of datafile is data_20201016_system.json - the numbers is the date of the current day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I in a simple way load these files ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use SAS DI or SAS EG.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the libname but it fails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;my code is here:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dato_d=%sysfunc(putn(%eval(%sysfunc(today())-3),yymmddn8.));&lt;BR /&gt;%put &amp;amp;dato_d;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname IN json '\\DW\Data\data_"&amp;amp;dato_d."_system.json' map='user.map' automap=create;&lt;/P&gt;&lt;P&gt;libname out '\\DW\Dataout';&lt;/P&gt;&lt;P&gt;data out.data_"&amp;amp;dato_d"_system;&lt;BR /&gt;set IN.ROOT;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;log&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4312 libname IN json&lt;BR /&gt;4312 ! '\\DW\data\data_"&amp;amp;dato_d."_system.json'&lt;BR /&gt;4312 ! map='user.map' automap=create;&lt;BR /&gt;ERROR: Invalid physical name.&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;4313&lt;BR /&gt;4314 libname out '\\DW\Dataout';&lt;BR /&gt;NOTE: Libref OUT was successfully assigned as follows:&lt;BR /&gt;163 The SAS System 17:12 Friday, October 16, 2020&lt;/P&gt;&lt;P&gt;Engine: V9&lt;BR /&gt;Physical Name: \\\\DW\Dataout&lt;BR /&gt;4315&lt;BR /&gt;4316 data out.data_"&amp;amp;dato_d"_system;&lt;BR /&gt;NOTE: Line generated by the macro variable "DATO_D".&lt;BR /&gt;4316 "20201013&lt;BR /&gt;_________&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space&lt;BR /&gt;between a quoted string and the succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;4317 set IN.ROOT;&lt;BR /&gt;ERROR: Libref IN is not assigned.&lt;BR /&gt;4318 run;&lt;/P&gt;&lt;P&gt;ERROR: The value '20201013'n is not a valid SAS name.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set OUT.DATA_ may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;BR /&gt;WARNING: Data set OUT.DATA_ was not replaced because this step was stopped.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Oct 2020 16:09:09 GMT</pubDate>
    <dc:creator>ANLYNG</dc:creator>
    <dc:date>2020-10-16T16:09:09Z</dc:date>
    <item>
      <title>read daily json datafiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692158#M210791</link>
      <description>&lt;P&gt;I need to read daily supplied json files on a dynamic way eg. name of datafile is data_20201016_system.json - the numbers is the date of the current day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I in a simple way load these files ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use SAS DI or SAS EG.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the libname but it fails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;my code is here:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dato_d=%sysfunc(putn(%eval(%sysfunc(today())-3),yymmddn8.));&lt;BR /&gt;%put &amp;amp;dato_d;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname IN json '\\DW\Data\data_"&amp;amp;dato_d."_system.json' map='user.map' automap=create;&lt;/P&gt;&lt;P&gt;libname out '\\DW\Dataout';&lt;/P&gt;&lt;P&gt;data out.data_"&amp;amp;dato_d"_system;&lt;BR /&gt;set IN.ROOT;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;log&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4312 libname IN json&lt;BR /&gt;4312 ! '\\DW\data\data_"&amp;amp;dato_d."_system.json'&lt;BR /&gt;4312 ! map='user.map' automap=create;&lt;BR /&gt;ERROR: Invalid physical name.&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;4313&lt;BR /&gt;4314 libname out '\\DW\Dataout';&lt;BR /&gt;NOTE: Libref OUT was successfully assigned as follows:&lt;BR /&gt;163 The SAS System 17:12 Friday, October 16, 2020&lt;/P&gt;&lt;P&gt;Engine: V9&lt;BR /&gt;Physical Name: \\\\DW\Dataout&lt;BR /&gt;4315&lt;BR /&gt;4316 data out.data_"&amp;amp;dato_d"_system;&lt;BR /&gt;NOTE: Line generated by the macro variable "DATO_D".&lt;BR /&gt;4316 "20201013&lt;BR /&gt;_________&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space&lt;BR /&gt;between a quoted string and the succeeding identifier is recommended.&lt;/P&gt;&lt;P&gt;4317 set IN.ROOT;&lt;BR /&gt;ERROR: Libref IN is not assigned.&lt;BR /&gt;4318 run;&lt;/P&gt;&lt;P&gt;ERROR: The value '20201013'n is not a valid SAS name.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set OUT.DATA_ may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;BR /&gt;WARNING: Data set OUT.DATA_ was not replaced because this step was stopped.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2020 16:09:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692158#M210791</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2020-10-16T16:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: read daily json datafiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692159#M210792</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
libname IN json "\\DW\Data\data_&amp;amp;dato_d._system.json" map='user.map' automap=create;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remove the inside double quotes and change the outer ones to double from single.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should work for you now.&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/26102"&gt;@ANLYNG&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I need to read daily supplied json files on a dynamic way eg. name of datafile is data_20201016_system.json - the numbers is the date of the current day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I in a simple way load these files ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use SAS DI or SAS EG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried the libname but it fails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;my code is here:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let dato_d=%sysfunc(putn(%eval(%sysfunc(today())-3),yymmddn8.));&lt;BR /&gt;%put &amp;amp;dato_d;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;libname IN json '\\DW\Data\data_"&amp;amp;dato_d."_system.json' map='user.map' automap=create;&lt;/P&gt;
&lt;P&gt;libname out '\\DW\Dataout';&lt;/P&gt;
&lt;P&gt;data out.data_"&amp;amp;dato_d"_system;&lt;BR /&gt;set IN.ROOT;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;log&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4312 libname IN json&lt;BR /&gt;4312 ! '\\DW\data\data_"&amp;amp;dato_d."_system.json'&lt;BR /&gt;4312 ! map='user.map' automap=create;&lt;BR /&gt;ERROR: Invalid physical name.&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;4313&lt;BR /&gt;4314 libname out '\\DW\Dataout';&lt;BR /&gt;NOTE: Libref OUT was successfully assigned as follows:&lt;BR /&gt;163 The SAS System 17:12 Friday, October 16, 2020&lt;/P&gt;
&lt;P&gt;Engine: V9&lt;BR /&gt;Physical Name: \\\\DW\Dataout&lt;BR /&gt;4315&lt;BR /&gt;4316 data out.data_"&amp;amp;dato_d"_system;&lt;BR /&gt;NOTE: Line generated by the macro variable "DATO_D".&lt;BR /&gt;4316 "20201013&lt;BR /&gt;_________&lt;BR /&gt;49&lt;BR /&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space&lt;BR /&gt;between a quoted string and the succeeding identifier is recommended.&lt;/P&gt;
&lt;P&gt;4317 set IN.ROOT;&lt;BR /&gt;ERROR: Libref IN is not assigned.&lt;BR /&gt;4318 run;&lt;/P&gt;
&lt;P&gt;ERROR: The value '20201013'n is not a valid SAS name.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set OUT.DATA_ may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;BR /&gt;WARNING: Data set OUT.DATA_ was not replaced because this step was stopped.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2020 16:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692159#M210792</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-16T16:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: read daily json datafiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692166#M210795</link>
      <description>&lt;P&gt;Just remove the random quotes.&amp;nbsp; Only put the quotes where the SAS syntax needs them.&lt;/P&gt;
&lt;P&gt;Also you don't need the %EVAL() as %sysfunc() will evaluate normal SAS expressions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dato_d=%sysfunc(putn(%sysfunc(today())-3,yymmddn8.));
%put &amp;amp;=dato_d;

libname IN json "\\DW\Data\data_&amp;amp;dato_d._system.json" 
  map='user.map' automap=create
;
libname out '\\DW\Dataout';

data out.data_&amp;amp;dato_d._system;
  set IN.ROOT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Oct 2020 16:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692166#M210795</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-16T16:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: read daily json datafiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692167#M210796</link>
      <description>Thank you very much for your solution. It works as expected now.</description>
      <pubDate>Fri, 16 Oct 2020 16:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692167#M210796</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2020-10-16T16:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: read daily json datafiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692191#M210809</link>
      <description>%let dato_d = %sysfunc( today() - 3, yymmddn8.);</description>
      <pubDate>Fri, 16 Oct 2020 17:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692191#M210809</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-16T17:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: read daily json datafiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692194#M210812</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;%let dato_d = %sysfunc( today() - 3, yymmddn8.);&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is not going to work.&amp;nbsp; The TODAY() function needs to be wrapped in %SYSFUNC().&lt;/P&gt;
&lt;P&gt;You could use the second argument to %SYSFUNC() to reference a format, but you cannot also do the subtraction.&amp;nbsp; &amp;nbsp;So you could do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dato_d = %sysfunc( today() , yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But to subtract the 3 days you need to do more.&amp;nbsp; So you could use PUTN() to format the result of subtracting 3.&lt;/P&gt;
&lt;P&gt;And you can do that without an explicit call to %EVAL() when it is in the argument passed to the PUTN() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dato_d = %sysfunc(putn( %sysfunc(today()) - 3, yymmddn8.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Oct 2020 17:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-daily-json-datafiles/m-p/692194#M210812</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-16T17:48:21Z</dc:date>
    </item>
  </channel>
</rss>

