<?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 data _null_ put   &amp;quot;embed SAS code&amp;quot;  in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358057#M274340</link>
    <description>&lt;P&gt;Hello all;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want use data step generate external&amp;nbsp;file.&amp;nbsp;the put statment does not work(need to keep the enter between rows) and need to be revised. please help.(I don't want add "put" in each line, because the real program has hundreds lines of codes)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&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;PRE&gt;Filename  need  "c:\temp\newcode.sas";
data _null_;
file need;
*------------ the code below need to be print to external file "newcode.sas*"------------------;
put 
"
/*Program name  newcode.sas*/
/*This SAS program will print sashelp.class*/
proc print data=sashelp.class;
run;
";
*-----------------------end -------------------------------;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 May 2017 22:37:44 GMT</pubDate>
    <dc:creator>GeorgeSAS</dc:creator>
    <dc:date>2017-05-11T22:37:44Z</dc:date>
    <item>
      <title>data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358057#M274340</link>
      <description>&lt;P&gt;Hello all;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want use data step generate external&amp;nbsp;file.&amp;nbsp;the put statment does not work(need to keep the enter between rows) and need to be revised. please help.(I don't want add "put" in each line, because the real program has hundreds lines of codes)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&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;PRE&gt;Filename  need  "c:\temp\newcode.sas";
data _null_;
file need;
*------------ the code below need to be print to external file "newcode.sas*"------------------;
put 
"
/*Program name  newcode.sas*/
/*This SAS program will print sashelp.class*/
proc print data=sashelp.class;
run;
";
*-----------------------end -------------------------------;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 22:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358057#M274340</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-05-11T22:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358058#M274341</link>
      <description>&lt;P&gt;Have you looked into PROC PRINTTO?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to put the text in quotes to output it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 22:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358058#M274341</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-11T22:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358059#M274342</link>
      <description>&lt;P&gt;As you've seen, each PUT statement writes to one line (at least, by default). &amp;nbsp;That gives you one possible solution: &amp;nbsp;multiple PUT statements:&lt;/P&gt;
&lt;PRE&gt;put "/*Program name  newcode.sas*/";
put "/*This SAS program will print sashelp.class*/";
put "proc print data=sashelp.class;";&lt;BR /&gt;put "run;";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not elegant, but at least it works. &amp;nbsp;Alternatively, a slash in a PUT statements tells SAS to move to the next line. &amp;nbsp;That means a single PUT statement can write out multiple pieces of text, to multiple lines, in this fashion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;put "/*Program name  newcode.sas*/"&lt;BR /&gt;  / "/*This SAS program will print sashelp.class*/"&lt;BR /&gt;  / "proc print data=sashelp.class;"&lt;BR /&gt;  / "run;"&lt;BR /&gt;  ;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 May 2017 22:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358059#M274342</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-11T22:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358061#M274343</link>
      <description>&lt;P&gt;Are you just trying to write out to a text file the SAS program code you want?&lt;/P&gt;
&lt;P&gt;One put statement will only generate one end of line unless you embedd the appropriate character(s) as a variable&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;data _null_;
file need;
*------------ the code below need to be print to external file "newcode.sas*"------------------;
put "/*Program name  newcode.sas*/";
put "/*This SAS program will print sashelp.class*/";
put "proc print data=sashelp.class;";
put "run;";
*-----------------------end -------------------------------;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 May 2017 22:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358061#M274343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-11T22:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358062#M274344</link>
      <description>&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/037-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/037-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My guess is you're trying to accomplish something similar to this.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 22:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358062#M274344</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-11T22:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358064#M274345</link>
      <description>&lt;P&gt;Given your example, what do you want the result to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 23:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358064#M274345</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-11T23:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358094#M274346</link>
      <description>&lt;P&gt;I want to create a new SAS program "c:\temp\newcode.sas" The full codes inside the file is:&lt;BR /&gt;&lt;BR /&gt;/*Program name newcode.sas*/&lt;BR /&gt;/*This SAS program will print sashelp.class*/&lt;BR /&gt;proc print data=sashelp.class;&lt;BR /&gt;run;&lt;BR /&gt;data a;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;My question is I can use data _null_ step to create the file? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 02:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358094#M274346</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-05-12T02:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358099#M274347</link>
      <description>&lt;PRE&gt;data _null_;
  file 'c:\temp\newcode.sas';
  put ' /*Program name newcode.sas*/';
  put '/*This SAS program will print sashelp.class*/';
  put 'proc print data=sashelp.class;';
  put 'run;';
  put 'data a;';
  put 'set sashelp.class;';
  put 'run;';
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 02:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358099#M274347</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-12T02:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358149#M274348</link>
      <description>Just out of curiosity, since there have some similar posts. What is the requirement / overall solution / process that makes you want to this (way)?</description>
      <pubDate>Fri, 12 May 2017 06:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358149#M274348</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-05-12T06:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358776#M274349</link>
      <description>&lt;P&gt;*----------------C:\temp\test\aa.txt--------------------------------;&lt;BR /&gt; /*Program name newcode.sas*/&lt;BR /&gt;/*This SAS program will print sashelp.class*/&lt;BR /&gt;proc print data=sashelp.class;&lt;BR /&gt;run;&lt;BR /&gt;data a;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;*----------------------------------------------;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data textdata;
infile "C:\temp\test\aa.txt" truncover;
input textline $100.;
run;
data textdata2;
length z $200;
set textdata;
z=cat("put '",strip(textline),"';");
run;
data textdata3;
set textdata2;
file "C:\temp\test\aa2.txt";
put z;
run;
data _null_;
file 'C:\temp\test\aa3.sas';
%include "C:\temp\test\aa2.txt";
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also thank Tom's good code,that works better:&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; file "c:\temp\newcode72.sas" ;&lt;BR /&gt; input;&lt;BR /&gt; put _infile_;&lt;BR /&gt;cards4;&lt;BR /&gt;/*Program name newcode.sas*/&lt;BR /&gt;/*This SAS program will print sashelp.class*/&lt;BR /&gt;proc print data=sashelp.class;&lt;BR /&gt;run;&lt;BR /&gt;data a;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;run;&lt;BR /&gt;;;;;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 19:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358776#M274349</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-05-15T19:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: data _null_ put   "embed SAS code"  in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358790#M274350</link>
      <description>&lt;P&gt;As long as you are not running in a macro and the program code you want to copy does not include four semi-colons then you can use inline data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "c:\temp\newcode.sas" ;
  input;
  put _infile_;
cards4;
/*Program name newcode.sas*/
/*This SAS program will print sashelp.class*/
proc print data=sashelp.class;
run;
data a;
set sashelp.class;
run;
;;;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2017 16:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-null-put-quot-embed-SAS-code-quot-in-data-step/m-p/358790#M274350</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-15T16:48:49Z</dc:date>
    </item>
  </channel>
</rss>

