<?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: How to have %LET apply to only non-missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604291#M175181</link>
    <description>&lt;P&gt;Your macro code doesn't make any sense.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are using %SYSFUNC() to call the INPUTN() function.&amp;nbsp; As the value for inputn() to read you are passing in the constant text var1. Because you are using the informat of 3. the function is going to try and read just the first three of those characters, var, as a number.&amp;nbsp; &lt;STRONG&gt;That will always return a missing value.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To access the value a &lt;STRONG&gt;variable&lt;/STRONG&gt; named var1 you would need to use actual SAS code, not macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is it that you want to do in your data step?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you figure that out then you can think about whether or not you need to use any macro statements.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 21:08:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-14T21:08:11Z</dc:date>
    <item>
      <title>How to have %LET apply to only non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604286#M175179</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to set a macro variable called i using an existing variable in my dataset (which is numeric).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let i = %sysfunc(inputn(var1, 3.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that some records have var1 as correctly missing. I don't want those records to go through the macro I've set up anyway, but no matter how I try to set it up to run the macro conditionally, I'm getting error messages which indicate that SAS is trying to use the missing values of var1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example of something I tried:&lt;/P&gt;&lt;P&gt;%macro one;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if var1 ne . then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %let i = %sysfunc(inputn(var1, 3.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; %one;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if var1 ne . then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %one;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought that since the records where var1 is missing did not meet the if criteria, they would not be run through the macro and cause the error messages, but that has not been the case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 20:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604286#M175179</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2019-11-14T20:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to have %LET apply to only non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604287#M175180</link>
      <description>&lt;P&gt;In a datastep use call symputx to create a macro variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In an open code or macro definition, you could use %let . I hope you understand the macro compile time operation?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604287#M175180</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-14T21:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to have %LET apply to only non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604291#M175181</link>
      <description>&lt;P&gt;Your macro code doesn't make any sense.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are using %SYSFUNC() to call the INPUTN() function.&amp;nbsp; As the value for inputn() to read you are passing in the constant text var1. Because you are using the informat of 3. the function is going to try and read just the first three of those characters, var, as a number.&amp;nbsp; &lt;STRONG&gt;That will always return a missing value.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To access the value a &lt;STRONG&gt;variable&lt;/STRONG&gt; named var1 you would need to use actual SAS code, not macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is it that you want to do in your data step?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you figure that out then you can think about whether or not you need to use any macro statements.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-have-LET-apply-to-only-non-missing-values/m-p/604291#M175181</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-14T21:08:11Z</dc:date>
    </item>
  </channel>
</rss>

