<?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 Macro variable while input to data cause zero missing in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/668754#M23180</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I meet a problem.&lt;/P&gt;
&lt;P&gt;while I want to insert a marco variable with zero at the front&amp;nbsp; &amp;nbsp;into a data.&lt;/P&gt;
&lt;P&gt;I found that the zero will be clean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because the p&lt;SPAN&gt;rocess of insert marco variable will change type by : marco variable-&amp;gt; num -&amp;gt; char.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And it will case the zero missing.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;%let i = 007;

data a;
ax=put(&amp;amp;i. , $4);
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*/output: 7 /*&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jul 2020 08:02:24 GMT</pubDate>
    <dc:creator>Sas_user_14</dc:creator>
    <dc:date>2020-07-13T08:02:24Z</dc:date>
    <item>
      <title>Macro variable while input to data cause zero missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/668754#M23180</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I meet a problem.&lt;/P&gt;
&lt;P&gt;while I want to insert a marco variable with zero at the front&amp;nbsp; &amp;nbsp;into a data.&lt;/P&gt;
&lt;P&gt;I found that the zero will be clean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because the p&lt;SPAN&gt;rocess of insert marco variable will change type by : marco variable-&amp;gt; num -&amp;gt; char.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And it will case the zero missing.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;%let i = 007;

data a;
ax=put(&amp;amp;i. , $4);
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*/output: 7 /*&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 08:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/668754#M23180</guid>
      <dc:creator>Sas_user_14</dc:creator>
      <dc:date>2020-07-13T08:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable while input to data cause zero missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/668755#M23181</link>
      <description>&lt;P&gt;When your macro variable is resolved, this code is the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
ax=put(007 , $4);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;007 is a numeric literal with the value 7 (numbers do not have leading zeroes, leading zeroes can only be created by &lt;EM&gt;numeric&lt;/EM&gt; formats).&lt;/P&gt;
&lt;P&gt;But:&lt;/P&gt;
&lt;P&gt;Maxim 3: Read the Log:&lt;/P&gt;
&lt;PRE&gt; 72         
 73         %let i = 007;
 74         
 75         data a;
 76         ax=put(&amp;amp;i. , $4);
                         _
                         85
                         76
 ERROR 85-322: Expecting a format name.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 77         run;&lt;/PRE&gt;
&lt;P&gt;Your incorrect use of a format (missing dot) causes a syntax ERROR.&lt;/P&gt;
&lt;P&gt;After correction, we get this:&lt;/P&gt;
&lt;PRE&gt; 73         %let i = 007;
 74         
 75         data a;
 76         ax=put(&amp;amp;i. , $4.);
 WARNING: Variable 007 has already been defined as numeric.
 77         run;&lt;/PRE&gt;
&lt;P&gt;which is a consequence of your use of a &lt;EM&gt;character&lt;/EM&gt; format for a &lt;EM&gt;numeric&lt;/EM&gt; value.&lt;/P&gt;
&lt;P&gt;So we need to use a proper numeric format that displays leading zeroes, and with the correct number of digits:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let i = 007;

data a;
ax=put(&amp;amp;i. , z3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But since you want a character value, this is accomplished in a much much simpler way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let i = 007;

data a;
ax = "&amp;amp;i.";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;by directly creating a character value from your macro variable.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 08:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/668755#M23181</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-13T08:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable while input to data cause zero missing</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/669125#M23197</link>
      <description>Thanks for answering !!</description>
      <pubDate>Tue, 14 Jul 2020 09:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-variable-while-input-to-data-cause-zero-missing/m-p/669125#M23197</guid>
      <dc:creator>Sas_user_14</dc:creator>
      <dc:date>2020-07-14T09:05:33Z</dc:date>
    </item>
  </channel>
</rss>

