<?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 Define Datafile Within Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531198#M145347</link>
    <description>&lt;P&gt;Windows 10, SAS Version 9.4&lt;/P&gt;&lt;P&gt;I would like to add 2 observations to a dataset.&amp;nbsp; To do so, I wrote the following code within a macro prior to&amp;nbsp;sort and merge by variable named&amp;nbsp;"compound2" of type char&amp;nbsp;$3.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.addcompounds2GFC;
		input compound2=$3. GFC_Suc_MPB= Final_Weigh_SD=;
		datalines;
 			compound2=Cl GFC_Suc_MPB=0 Final_Weigh_SD=0
			compound2=S  GFC_Suc_MPB=0 Final_Weigh_SD=0
			; 

proc print data=work.addcompounds2GFC; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;When I compile just the code as shown above, the result is just the desired&amp;nbsp;dataset (work.addcompounds2GFC).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.JPG" style="width: 351px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26686iF6F36CD9E228BE08/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.JPG" alt="1.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was also able to do this using cards:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.addcompounds2GFC;
				length compound2 $3;
				input compound2 $ GFC_Suc_MPB Final_Weigh_SD;
				cards;
					Cl 0 0
					S 0 0
			; 
			run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code is nested within a macro.&amp;nbsp; While compilation works in pieces, running the macro as a whole leads to the following error message:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: The macro RUN4_CALCULATIONS generated CARDS (data lines) for the DATA step, which could
       cause incorrect results.  The DATA step and the macro will stop executing.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want, and this works if I just run a portion of code within the macro,&amp;nbsp;is to combine this data with another dataset&amp;nbsp;with the new observations for Cl and S:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.JPG" style="width: 374px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26687i7EB2C4B0523E0543/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.JPG" alt="2.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, Jane&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jan 2019 22:21:28 GMT</pubDate>
    <dc:creator>jawhitmire</dc:creator>
    <dc:date>2019-01-29T22:21:28Z</dc:date>
    <item>
      <title>Define Datafile Within Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531198#M145347</link>
      <description>&lt;P&gt;Windows 10, SAS Version 9.4&lt;/P&gt;&lt;P&gt;I would like to add 2 observations to a dataset.&amp;nbsp; To do so, I wrote the following code within a macro prior to&amp;nbsp;sort and merge by variable named&amp;nbsp;"compound2" of type char&amp;nbsp;$3.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.addcompounds2GFC;
		input compound2=$3. GFC_Suc_MPB= Final_Weigh_SD=;
		datalines;
 			compound2=Cl GFC_Suc_MPB=0 Final_Weigh_SD=0
			compound2=S  GFC_Suc_MPB=0 Final_Weigh_SD=0
			; 

proc print data=work.addcompounds2GFC; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;When I compile just the code as shown above, the result is just the desired&amp;nbsp;dataset (work.addcompounds2GFC).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.JPG" style="width: 351px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26686iF6F36CD9E228BE08/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.JPG" alt="1.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was also able to do this using cards:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.addcompounds2GFC;
				length compound2 $3;
				input compound2 $ GFC_Suc_MPB Final_Weigh_SD;
				cards;
					Cl 0 0
					S 0 0
			; 
			run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code is nested within a macro.&amp;nbsp; While compilation works in pieces, running the macro as a whole leads to the following error message:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: The macro RUN4_CALCULATIONS generated CARDS (data lines) for the DATA step, which could
       cause incorrect results.  The DATA step and the macro will stop executing.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want, and this works if I just run a portion of code within the macro,&amp;nbsp;is to combine this data with another dataset&amp;nbsp;with the new observations for Cl and S:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.JPG" style="width: 374px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26687i7EB2C4B0523E0543/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.JPG" alt="2.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, Jane&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 22:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531198#M145347</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-01-29T22:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Define Datafile Within Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531199#M145348</link>
      <description>You cannot use cards or data lines within a macro. However you can use SQL INSERT instead.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=sqlproc&amp;amp;docsetTarget=n1ncn0pznd8wrln1tnp3xdxjz9xz.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=sqlproc&amp;amp;docsetTarget=n1ncn0pznd8wrln1tnp3xdxjz9xz.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;</description>
      <pubDate>Tue, 29 Jan 2019 22:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531199#M145348</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-29T22:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Define Datafile Within Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531203#M145350</link>
      <description>&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The information at the link was informative and the following correction fixed the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
				create table work.addcompounds2GFC(compound2 char(3), GFC_Suc_MPB num, Final_Weigh_SD num);
				insert into work.addcompounds2GFC
					values('S',0,0)
					values('Cl',0,0);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks again. Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 22:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-Datafile-Within-Macro/m-p/531203#M145350</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-01-29T22:53:44Z</dc:date>
    </item>
  </channel>
</rss>

