<?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 logical expresion macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131874#M35852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hy everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how can I write this expression inside of a macro,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if stat in ('MEAN','MIN','MAX') %then format &amp;amp;macrovariable 6.2;....(I know I can write three times&amp;nbsp; %if&amp;nbsp; stat= ' X'&amp;nbsp; %then ....) but,&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;are the logical (in, not in, or, and) recognize inside of a macro?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Jun 2012 13:44:08 GMT</pubDate>
    <dc:creator>michtka</dc:creator>
    <dc:date>2012-06-04T13:44:08Z</dc:date>
    <item>
      <title>logical expresion macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131874#M35852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hy everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how can I write this expression inside of a macro,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if stat in ('MEAN','MIN','MAX') %then format &amp;amp;macrovariable 6.2;....(I know I can write three times&amp;nbsp; %if&amp;nbsp; stat= ' X'&amp;nbsp; %then ....) but,&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;are the logical (in, not in, or, and) recognize inside of a macro?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2012 13:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131874#M35852</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-06-04T13:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: logical expresion macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131875#M35853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michtka,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you are trying to make SAS do things that it just won't do.&amp;nbsp; It looks like you are trying to process a SAS data set using macro language.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just for the record, macro language does contain an IN operator, usually using the # character.&amp;nbsp; It was introduced in 9.2, but not really working until 9.3.&amp;nbsp; So you have to be running 9.3 to be able to use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The bigger point though is that it seems you are trying to process a SAS data set using macro language.&amp;nbsp; That just won't happen.&amp;nbsp; For example, a macro language statement that begins %if stat = 'MEAN' will compare four characters ("stat") to six characters ("'MEAN'") and find that they are never equal.&amp;nbsp; I suspect that you have a SAS data set that contains a variable named STAT.&amp;nbsp; A macro language %IF statement will only examine the value of a macro variable, never the value of a DATA step variable.&amp;nbsp; A secondary issue would be that a format for a DATA step variable cannot change from one observation to the next.&amp;nbsp; The format applies to the entire column of data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I've interpreted this wrong, and your problem is really something else, you can always add a description of your inputs and desired outputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2012 15:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131875#M35853</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-06-04T15:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: logical expresion macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131876#M35854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; Astounding is correct, that you cannot test data set variables in a macro program. However, using PROC REPORT, you can apply one format for one value in a report row, versus another format for a different value. For example, suppose I use PROC SUMMARY on SASHELP.SHOES to get the standard 5 statistics into a data set. Then I can format each statistic separately using CALL DEFINE in PROC REPORT. This is a REPORT (not a dataset) generated by PROC REPORT. Notice the different formats for each report row for the Sales column, but the condition for the format was based on the value of the _STAT_ column (created by PROC MEANS/SUMMARY):&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;Stat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sales&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;N&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 395&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;MIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $325.00&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;MAX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,298,717.00&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;MEAN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $85,700.17&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;STD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 129,107.2339&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not quite what the OP originally described, but PROC REPORT does have this flexibility. Code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;proc summary data=sashelp.shoes;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;var sales;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;output out=work.statsales / autoname;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;proc report data=work.statsales nowd;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; column _stat_ sales;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define _stat_ / display 'Stat';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define sales / display 'Sales';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; compute sales;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _stat_ = 'N' then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call define(_col_,'format','comma6.');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _stat_ in ('MIN', 'MEAN') then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call define(_col_,'format','dollar16.2');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _stat_ = 'MAX' then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call define(_col_,'format','comma16.2');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _stat_ = 'STD' then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call define(_col_,'format','comma20.4');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; endcomp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2012 15:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131876#M35854</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-06-04T15:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: logical expresion macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131877#M35855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you want data step to reformat data differently based on value in another variable.&lt;/P&gt;&lt;P&gt;You will need to store this into a character variable. You can use the PUTN() function to do this.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;if stat in ('MEAN','MIN','MAX') then charvar= putn(numvar,"6.2");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;else if stat = 'N' then charvar=putn(numvar,6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;else charvar='UNK STAT';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jun 2012 16:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131877#M35855</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-04T16:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: logical expresion macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131878#M35856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Guys, it was a mistake...now i understood the concept of using macrovariables with the Astounding's explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes Tom, it was my idea.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 01:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logical-expresion-macro/m-p/131878#M35856</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-06-05T01:22:54Z</dc:date>
    </item>
  </channel>
</rss>

