<?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: CALL SYMPUT within a macro generated using CALL EXECUTE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745416#M233644</link>
    <description>It is a timing issue, as already mentioned.&lt;BR /&gt;Apart from that, be careful with CALL SYMPUT. Rather use CALL SYMPUTX with L as the third argument, so you do not accidentally mess up variables in an outer macro scope.</description>
    <pubDate>Thu, 03 Jun 2021 08:56:15 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-06-03T08:56:15Z</dc:date>
    <item>
      <title>CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745391#M233634</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a directory with hundreds of JSON files. Some are empty.&lt;/P&gt;
&lt;P&gt;I want to import the non-empty files and append them to one dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO ImportDataTop(dset=,dfile=);
    /* First test to see if the file is not an empty JSON string */
    DATA NULL;
        INFILE "&amp;amp;DataDir.&amp;amp;dfile" LRECL=256 TRUNCOVER;
        INPUT Ln $256.;
        IF _N_ EQ 1 THEN DO;
            IF Ln EQ "{}" THEN CALL SYMPUT("JSONTest",0); ELSE CALL SYMPUT("JSONTest",1);
        END;
    RUN;
    %PUT &amp;amp;JSONTest;
    %IF &amp;amp;JSONTest EQ 1 %THEN %DO;
        /* Use the SAS json reader in LIBNAME to automatically read the files */
        LIBNAME tmpFile JSON "&amp;amp;DataDir.&amp;amp;dfile";
        DATA WORK.tmpFile;
            SET tmpFile.item;
        /* Do data calculations... */
        RUN;
        /* Append the data to a growing datafile */
            PROC DATASETS
                NOPRINT
                LIBRARY=MYLIB;
                APPEND BASE=&amp;amp;dset
                       DATA=WORK.tmpFile
                       FORCE;
            QUIT;
        PROC DELETE DATA=WORK.tmpFile; RUN;
    %END;
    %ELSE %DO;
        %PUT Blank JSON string in &amp;amp;dfile;
    %END;    
%MEND ImportDataTop;

/* Get the full list of data files */&lt;BR /&gt;FILENAME _FQuery PIPE "dir ""&amp;amp;DataDir.(*);AU*;*Queries;*;2021-06-02.json"" /b ";&lt;BR /&gt;DATA ListQueries;
    INFILE _FQuery LRECL=256 TRUNCOVER;
    INPUT file_name $256.;
run;

PROC DELETE DATA=MYLIB.CollatedDataSet;RUN;
DATA NULL;
    SET ListQueries;
    CALL EXECUTE(CATT('%ImportDataTop(dset=CollatedDataSet,dfile=',file_name,');'));
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But when I run this, &amp;amp;JSONTest is not processed properly. It is, from the %put statement, simply 1 all the time, regardless of the actual content of the file.&lt;/P&gt;
&lt;P&gt;I cannot seem to figure out why call symput is not giving me the correct value into &amp;amp;JSONTest. Using options mprint, it seems as if SAS is generating all the code for each call execute iteration without actually doing the test I have coded in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 05:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745391#M233634</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-06-03T05:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745405#M233639</link>
      <description>You are observing a feature of call execute.  It immediately executes macro language statements such as %if %then, but must wait to execute SAS language statements such as call symput.  To solve this issue, wrap the executed macro call in %nrstr:&lt;BR /&gt;&lt;BR /&gt;call execute (CATT(%nrstr('%ImportanceDataTop'), 'dset=.....));</description>
      <pubDate>Thu, 03 Jun 2021 07:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745405#M233639</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-06-03T07:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745408#M233641</link>
      <description>&lt;P&gt;Nope, that is just causing errors with the macro variables in the procedure:&lt;/P&gt;
&lt;P&gt;NOTE: CALL EXECUTE generated line.&lt;BR /&gt;1 + DATA NULL; INFILE "c:\Users\j...\C...\" LRECL=256&lt;BR /&gt;TRUNCOVER; INPUT Ln $256.; IF _N_ EQ 1 THEN DO; IF Ln&lt;BR /&gt;2 + EQ "{}" THEN CALL SYMPUT("JSONTest",0); ELSE CALL SYMPUT("JSONTest",1); END;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;2:38 2:70&lt;BR /&gt;ERROR: Invalid file, c:\Users\j...\C... .&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.NULL may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 1 variables.&lt;BR /&gt;WARNING: Data set WORK.NULL was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 +&lt;BR /&gt;LIBNAME tmpFile JSON "c:\Users\j...\C...\";&lt;BR /&gt;NOTE: JSON data is only read once. To read the JSON again, reassign the JSON LIBNAME.&lt;BR /&gt;ERROR: Invalid file, c:\Users\j...\C... .&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 08:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745408#M233641</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-06-03T08:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745416#M233644</link>
      <description>It is a timing issue, as already mentioned.&lt;BR /&gt;Apart from that, be careful with CALL SYMPUT. Rather use CALL SYMPUTX with L as the third argument, so you do not accidentally mess up variables in an outer macro scope.</description>
      <pubDate>Thu, 03 Jun 2021 08:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745416#M233644</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-03T08:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745417#M233645</link>
      <description>A NOTE about conversion of numeric to character or character to numeric is always a BAD THING.&lt;BR /&gt;Using 0 as second argument to CALL SYMPUT causes a conversion with the default format of BEST12., so you get a string containing 11 blanks and the 0. Since CALL SYMPUT will not strip the blanks, the comparison fails. Another reason to use CALL SYMPUTX, which converts on its own (no NOTE) and strips leading and trailing blanks.</description>
      <pubDate>Thu, 03 Jun 2021 09:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745417#M233645</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-03T09:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745429#M233649</link>
      <description>&lt;P&gt;I'm sorry if I seem slow, but I'm still not getting it.&lt;/P&gt;
&lt;P&gt;Even if I use something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF Ln EQ "{}" THEN CALL SYMPUTX("JSONTest","A","L"); ELSE CALL SYMPUTX("JSONTest","B","L");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The value of &amp;amp;JSONTest does not change from iteration to iteration of the call execute.&lt;/P&gt;
&lt;P&gt;And this is despite the value of ln eq "{}" changing from iteration to iteration.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 10:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745429#M233649</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-06-03T10:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745465#M233666</link>
      <description>&lt;P&gt;Did you use %NRSTR?&lt;/P&gt;
&lt;P&gt;Are there no leading blanks in variable ln?&lt;/P&gt;
&lt;P&gt;Are there no un-displayable characters in ln?&lt;/P&gt;
&lt;P&gt;Run the code in a new SAS session, to make sure that no previous macro variable jsontest exists in the global scope.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 13:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745465#M233666</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-03T13:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745476#M233673</link>
      <description>&lt;P&gt;As was mentioned, %nrstr is going to be key here.&amp;nbsp; In the meantime, here are a few minor issues to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't ignore log messages.&amp;nbsp; When you have numeric to character conversion, it indicates you are not necessarily getting the results you expected in that step.&amp;nbsp; So figure out why that happens and address it.&amp;nbsp; One of the log messages mentioned that a file doesn't actually exist.&amp;nbsp; So that needs attention.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this step, minor changes are indicated:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    DATA NULL;
        INFILE "&amp;amp;DataDir.&amp;amp;dfile" LRECL=256 TRUNCOVER;
        INPUT Ln $256.;
        IF _N_ EQ 1 THEN DO;
            IF Ln EQ "{}" THEN CALL SYMPUT("JSONTest",0); ELSE CALL SYMPUT("JSONTest",1);
        END;
    RUN;
    %PUT &amp;amp;JSONTest;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's assume you already switched from SYMPUT to SYMPUTX.&amp;nbsp; That may or may not have an impact on the rest of the program, depending on which set of code you are actually using.&amp;nbsp; (I can see from your posts you have experimented with a few variations.)&amp;nbsp; Two more changes are indicated:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    DATA _NULL_;
        INFILE "&amp;amp;DataDir.&amp;amp;dfile" LRECL=256 TRUNCOVER;
        INPUT Ln $256.;
        IF _N_ EQ 1;
        IF Ln EQ "{}" THEN CALL SYMPUT("JSONTest",0);    
        ELSE CALL SYMPUT("JSONTest",1);
        STOP;
    RUN;
    %PUT *&amp;amp;JSONTest*;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NULL is actually a data set name.&amp;nbsp; You can see the log messages about the data set NULL.&amp;nbsp; To avoid creating a data set, while going through the motions of a DATA step (appropriate in this case), use _NULL_ instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once that data step has read in the first line, there is no need to read in any more data.&amp;nbsp; Your current data step reads in every line, most of which you don't really need.&amp;nbsp; So once SYMPUTX has executed, STOP the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, the %PUT statement should write out a clearer message that will point out whether you have extra characters in your macro variable.&amp;nbsp; One way is to add the asterisks in the sample code above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Despite all this, %nrstr will still be necessary and the key to successful debugging.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 14:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745476#M233673</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-06-03T14:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745481#M233677</link>
      <description>&lt;P&gt;To avoid timing issue caused when the macro executes wrap the macro name into %NRSTR() .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
    SET ListQueries;
    CALL EXECUTE(CATT('%nrstr(%ImportDataTop)(dset=CollatedDataSet,dfile=',file_name,');'));
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It will also make the SAS log easier to read.&lt;/P&gt;
&lt;P&gt;So now your log will look like:&lt;/P&gt;
&lt;PRE&gt;+    %ImportDataTop(dset=CollatedDataSet,dfile=...&lt;/PRE&gt;
&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;+    DATA NULL; INFILE "...&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jun 2021 14:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745481#M233677</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-03T14:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745491#M233684</link>
      <description>&lt;P&gt;The timing of CALL EXECUTE is tricky.&amp;nbsp; It might help if you start with a very simple example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This macro reads in a dataset and uses CALL SYMPUT to write a value the macro var NAME:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro try() ;
  %local name ;
  data _null_ ;
    set sashelp.class ;
    if _n_ EQ 1 then call symputx("Name",name) ;
  run ;
  %put &amp;amp;=name ;
%mend try ;

%try()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you invoke the macro with CALL EXECUTE, it does not work as you hoped:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  call execute('%try()') ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log is:&lt;/P&gt;
&lt;PRE&gt;510   data _null_ ;
511     call execute('%try()') ;
512   run ;

MPRINT(TRY):   data _null_ ;
MPRINT(TRY):   set sashelp.class ;
MPRINT(TRY):   if _n_ EQ 1 then call symputx("Name",name) ;
MPRINT(TRY):   run ;
NAME=
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1    + data _null_ ;     set sashelp.class ;     if _n_ EQ 1 then call symputx("Name",name) ;   run ;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

&lt;/PRE&gt;
&lt;P&gt;So the macro variable NAME is still empty.&amp;nbsp; This happened because of the referenced timing problem.&amp;nbsp; CALL EXECUTE actually executed the macro, and when it did that it generated all the SAS code and executed that the macro statements.&amp;nbsp; So the %PUT &amp;amp;=Name statement executes *before* the data _null_ step which writes a value to NAME has even compiled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wrap the macro call in %NRSTR(), it changes CALL EXECUTE from executing the macro, to only generating the macro call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  call execute('%nrstr(%try())') ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;523   data _null_ ;
524     call execute('%nrstr(%try())') ;
525   run ;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1    + %try()
MPRINT(TRY):   data _null_ ;
MPRINT(TRY):   set sashelp.class ;
MPRINT(TRY):   if _n_ EQ 1 then call symputx("Name",name) ;
MPRINT(TRY):   run ;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NAME=Alfred
&lt;/PRE&gt;
&lt;P&gt;Note that above, the line generated by CALL EXECUTE (with the + prefix) is only the macro call.&amp;nbsp; &amp;nbsp;This allows the 'usual' timing when the macro executes.&amp;nbsp; The DATA step is executed first, and then the %PUT statement is executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 15:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745491#M233684</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-06-03T15:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745633#M233771</link>
      <description>&lt;P&gt;Thanks for that tip about data null. Somehow, I seem to have got confused about that.&lt;/P&gt;
&lt;P&gt;I think in modifying my code, I was sloppy, as I did have it right in the macro, but didn't type it over correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 21:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745633#M233771</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-06-03T21:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: CALL SYMPUT within a macro generated using CALL EXECUTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745648#M233775</link>
      <description>&lt;P&gt;Thanks to all for the input.&lt;/P&gt;
&lt;P&gt;The system really should allow one to mark more than one answer as the solution.&lt;/P&gt;
&lt;P&gt;Here, then, is the working code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO ImportDataTop(dset=,dfile=);
    /* First test to see if the file is not an empty JSON string */
    DATA _NULL_;
        INFILE "&amp;amp;DataDir.&amp;amp;dfile" LRECL=256 TRUNCOVER;
        INPUT Ln $256.;
        IF _N_ EQ 1;
            IF Ln EQ "{}" THEN CALL SYMPUTX("JSONTest",0); ELSE CALL SYMPUTX("JSONTest",1);
        STOP;
    RUN;
    %PUT |&amp;amp;JSONTest.|;
    %IF &amp;amp;JSONTest EQ 1 %THEN %DO;
        /* Use the SAS json reader in LIBNAME to automatically read the files */
        LIBNAME tmpFile JSON "&amp;amp;DataDir.&amp;amp;dfile";
        DATA WORK.tmpFile;
            SET tmpFile.item;
        /* Do data calculations... */
        RUN;
        /* Append the data to a growing datafile */
            PROC DATASETS
                NOPRINT
                LIBRARY=MYLIB;
                APPEND BASE=&amp;amp;dset
                       DATA=WORK.tmpFile
                       FORCE;
            QUIT;
        PROC DELETE DATA=WORK.tmpFile; RUN;
    %END;
    %ELSE %DO;
        %PUT Blank JSON string in &amp;amp;dfile;
    %END;    
%MEND ImportDataTop;

/* Get the full list of data files */FILENAME _FQuery PIPE "dir ""&amp;amp;DataDir.(*);AU*;*Queries;*;2021-06-02.json"" /b ";DATA ListQueries;
    INFILE _FQuery LRECL=256 TRUNCOVER;
    INPUT file_name $256.;
run;

PROC DELETE DATA=MYLIB.CollatedDataSet;RUN;
DATA NULL;
    SET ListQueries;
    CALL EXECUTE(CATT('%NRSTR(%ImportDataTop)(dset=VaccineSearchesQueries,dfile=',file_name,');'));
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:37:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CALL-SYMPUT-within-a-macro-generated-using-CALL-EXECUTE/m-p/745648#M233775</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-06-03T22:37:58Z</dc:date>
    </item>
  </channel>
</rss>

