<?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: Data step put statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607387#M176559</link>
    <description>When I ran the code I got this error in the log.&lt;BR /&gt;&lt;BR /&gt;data bat;&lt;BR /&gt;&lt;BR /&gt;75 com2="rem@echo off";&lt;BR /&gt;&lt;BR /&gt;76 do i=1 to 3;&lt;BR /&gt;&lt;BR /&gt;77 com='call NMGO' || cats ("TEST",i);&lt;BR /&gt;&lt;BR /&gt;78 com1='call NMGO' || cats ("TEST",i,'.CTL -MAXLIM=3);&lt;BR /&gt;&lt;BR /&gt;79 output;&lt;BR /&gt;&lt;BR /&gt;80 end;&lt;BR /&gt;&lt;BR /&gt;81 run;&lt;BR /&gt;&lt;BR /&gt;82 data _null_;&lt;BR /&gt;&lt;BR /&gt;83 set bat;&lt;BR /&gt;&lt;BR /&gt;84 file&lt;BR /&gt;'/folders/myfolders/BOOTSTRAPAPTENSIO_PED/BATFILEPREP/boot.bat';&lt;BR /&gt;&lt;BR /&gt;85 IF _N_=1 THEN put com2 ;&lt;BR /&gt;&lt;BR /&gt;86 put @2 com1;&lt;BR /&gt;&lt;BR /&gt;84 file&lt;BR /&gt;'/folders/myfolders/BOOTSTRAPAPTENSIO_PED/BATFILEPREP/boot.bat';&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;________&lt;BR /&gt;&lt;BR /&gt;557&lt;BR /&gt;&lt;BR /&gt;ERROR 557-185: Variable boot is not an object.&lt;BR /&gt;&lt;BR /&gt;87 run;&lt;BR /&gt;&lt;BR /&gt;88&lt;BR /&gt;&lt;BR /&gt;89 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt;&lt;BR /&gt;90 ODS HTML CLOSE;&lt;BR /&gt;&lt;BR /&gt;91 &amp;amp;GRAPHTERM; ;*';*";*/;RUN;QUIT;&lt;BR /&gt;&lt;BR /&gt;ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION&lt;BR /&gt;phase.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 26 Nov 2019 15:50:18 GMT</pubDate>
    <dc:creator>jacksonan123</dc:creator>
    <dc:date>2019-11-26T15:50:18Z</dc:date>
    <item>
      <title>Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607367#M176544</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bat;
do i=1 to 3;
com2="rem@echo off";
com="call nmgo" || compress("TEST"||i);
com1="call nmgo" || compress("TEST"||i) ||COMPRESS(".CTL -MAXLIM=3"||""); 
output;
end;
run;
data _null_;
  set bat;
  file '/folders/myfolders/BOOTSTRAP_PED/BATFILEPREP/booti.bat';
  put @1 com2 ; 
  put @2 com1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have the attached code which works for what I want to do.&amp;nbsp; However for the put statement I need to limit the rem@echo off to the first line of booti.&amp;nbsp; What I have is this with rem@echo off in every other line:&lt;/P&gt;
&lt;PRE&gt;rem@echo off
CALL NMGO TEST1.CTL -MAXLIM=3

rem@echo off
CALL NMGO TEST2.CTL -MAXLIM=3&lt;/PRE&gt;
&lt;P&gt;&lt;FONT&gt;but what I want is this for the rem@echo off to appear in only line 1:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;rem@echo off
CALL NMGO TEST1.CTL -MAXLIM=3
CALL NMGO TEST2.CTL -MAXLIM=3&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607367#M176544</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2019-11-26T15:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607374#M176550</link>
      <description>&lt;P&gt;You can test the automatic iteration counter, _N_, to know when you are on the first iteration of the data step.&lt;/P&gt;
&lt;P&gt;Do you want the space after NMGO that appears in the example output or not?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bat;
  com2="rem@echo off";
  do i=1 to 3;
    com ='call nmgo' || cats("TEST",i);
    com1='CALL NMGO ' || cats("TEST",i,'.CTL -MAXLIM=3);
    output;
  end;
run;
data _null_;
  set bat;
  file '/folders/myfolders/BOOTSTRAP_PED/BATFILEPREP/booti.bat';
  if _n_=1 then put com2 ; 
  put @2 com1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607374#M176550</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-26T15:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607377#M176552</link>
      <description>&lt;P&gt;If I understand what you want try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set bat;
  file '/folders/myfolders/BOOTSTRAP_PED/BATFILEPREP/booti.bat';
  If _n_ = 1 then put @1 com2 ; 
  put @2 com1;
run;&lt;/PRE&gt;
&lt;P&gt;_n_ is an automatic variable that SAS increments at each "loop" through the data step. In this case it is, in effect, the "line read count".&lt;/P&gt;
&lt;P&gt;So test that variable and only create the output the first time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless you need that BAT data set elsewhere this could be done with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
   file 'your file';
   put @1 "rem@echo off";
   do i=1 to 3;
      com="call nmgo" || compress("TEST"||i);
      com1="call nmgo" || compress("TEST"||i) ||COMPRESS(".CTL -MAXLIM=3"||""); 
      put @2 com1;
   end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607377#M176552</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-26T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607387#M176559</link>
      <description>When I ran the code I got this error in the log.&lt;BR /&gt;&lt;BR /&gt;data bat;&lt;BR /&gt;&lt;BR /&gt;75 com2="rem@echo off";&lt;BR /&gt;&lt;BR /&gt;76 do i=1 to 3;&lt;BR /&gt;&lt;BR /&gt;77 com='call NMGO' || cats ("TEST",i);&lt;BR /&gt;&lt;BR /&gt;78 com1='call NMGO' || cats ("TEST",i,'.CTL -MAXLIM=3);&lt;BR /&gt;&lt;BR /&gt;79 output;&lt;BR /&gt;&lt;BR /&gt;80 end;&lt;BR /&gt;&lt;BR /&gt;81 run;&lt;BR /&gt;&lt;BR /&gt;82 data _null_;&lt;BR /&gt;&lt;BR /&gt;83 set bat;&lt;BR /&gt;&lt;BR /&gt;84 file&lt;BR /&gt;'/folders/myfolders/BOOTSTRAPAPTENSIO_PED/BATFILEPREP/boot.bat';&lt;BR /&gt;&lt;BR /&gt;85 IF _N_=1 THEN put com2 ;&lt;BR /&gt;&lt;BR /&gt;86 put @2 com1;&lt;BR /&gt;&lt;BR /&gt;84 file&lt;BR /&gt;'/folders/myfolders/BOOTSTRAPAPTENSIO_PED/BATFILEPREP/boot.bat';&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;________&lt;BR /&gt;&lt;BR /&gt;557&lt;BR /&gt;&lt;BR /&gt;ERROR 557-185: Variable boot is not an object.&lt;BR /&gt;&lt;BR /&gt;87 run;&lt;BR /&gt;&lt;BR /&gt;88&lt;BR /&gt;&lt;BR /&gt;89 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt;&lt;BR /&gt;90 ODS HTML CLOSE;&lt;BR /&gt;&lt;BR /&gt;91 &amp;amp;GRAPHTERM; ;*';*";*/;RUN;QUIT;&lt;BR /&gt;&lt;BR /&gt;ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION&lt;BR /&gt;phase.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607387#M176559</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2019-11-26T15:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607392#M176564</link>
      <description>&lt;P&gt;Please post log entries in a code box. By now you should have realized that the message windows reformat the text and make the diagnostic characters that SAS supplies appear in the wrong location as well as sometimes inserting extra newline characters.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607392#M176564</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-26T15:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607393#M176565</link>
      <description>&lt;P&gt;You are missing at least one closing quote mark in this line:&lt;/P&gt;
&lt;PRE&gt;78 com1='call NMGO' || cats ("TEST",i,'.CTL -MAXLIM=3);&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607393#M176565</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-26T15:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607394#M176566</link>
      <description>Works well.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Nov 2019 16:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607394#M176566</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2019-11-26T16:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607397#M176569</link>
      <description>I forgot about doing that, next time I will to avoid that mistake.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Nov 2019 16:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607397#M176569</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2019-11-26T16:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data step put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607401#M176573</link>
      <description>Your solution also works after I put in the missing (').&lt;BR /&gt;&lt;BR /&gt;Thanks for the help and it is accepted as a solution.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Nov 2019 16:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-put-statement/m-p/607401#M176573</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2019-11-26T16:07:18Z</dc:date>
    </item>
  </channel>
</rss>

