<?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: Problem with macro with where statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518558#M3576</link>
    <description>&lt;P&gt;Show us the SAS log as I described earlier.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2018 20:16:49 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-12-04T20:16:49Z</dc:date>
    <item>
      <title>Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518535#M3570</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original proc means statement is below, and I wanted to use a macro to run multiple variables, however, my macro did not work when&amp;nbsp;if I included the "&lt;SPAN&gt;where=(wrat_raw ne 888 or 999&lt;/SPAN&gt;" statement. Could anyone revise my code? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means data=nero2 (where=(wrat_raw ne 888 or 999)) mean std median min max ;&lt;BR /&gt;class site_id Phase visit_id;&lt;BR /&gt;var wrat_raw;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro one(x);&lt;BR /&gt;proc means n mean std median min max maxdec=1;&lt;BR /&gt;var &amp;amp;x;&lt;BR /&gt;class site_id Phase visit_id;&lt;BR /&gt;run;&lt;BR /&gt;%mend one;&lt;BR /&gt;%one (wrat_raw);&lt;BR /&gt;%one (wrat_ss);&lt;BR /&gt;%one (wrat_perc);&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 19:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518535#M3570</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-12-04T19:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518539#M3571</link>
      <description>&lt;P&gt;Please re-run your code where the new first line of the code is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then click on the {i} icon and paste the SAS log into the&amp;nbsp;window that appears.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We really can't provide proper assistance when all you tell us is that it "did not work". Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 19:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518539#M3571</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-04T19:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518545#M3572</link>
      <description>&lt;PRE&gt;where=(wrat_raw ne 888 or 999)) &lt;/PRE&gt;
&lt;P&gt;This selects all records because the OR is not using the variable wrat_raw and the 999 is sole comparison used. Since 999 is not 0 then the OR is always true&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;perhaps you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where= (wrat_raw not in (888 999) )&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 19:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518545#M3572</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-04T19:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518550#M3573</link>
      <description>&lt;P&gt;I tried the below code, but 888 still shows up as the maximum value.&amp;nbsp;&lt;BR /&gt;proc means data=nero2 (where=(wrat_raw ne 888 or wrat_raw ne 999)) mean std median min max maxdec=1;&lt;BR /&gt;class site_id Phase visit_id;&lt;BR /&gt;var wrat_raw;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do the data cleaning step in the beginning? 888 and 999 are both missing value, how do I define them as '.'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 20:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518550#M3573</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-12-04T20:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518555#M3575</link>
      <description>&lt;P&gt;I ran blow code and it worked. 888 is no longer the maximum value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means data=nero2 (where=(wrat_raw not in (888 999))) mean std median min max maxdec=1;&lt;BR /&gt;class site_id Phase visit_id;&lt;BR /&gt;var wrat_raw;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But my Macro seems to be wrong because I am still seeing 888 as maximum. Could you please revise my Macro below? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro one(x) (where=(wrat_raw not in (888 999)));&lt;BR /&gt;proc means n mean std median min max maxdec=1;&lt;BR /&gt;var &amp;amp;x;&lt;BR /&gt;class site_id Phase visit_id;&lt;BR /&gt;run;&lt;BR /&gt;%mend one;&lt;BR /&gt;%one (wrat_raw);&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 20:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518555#M3575</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-12-04T20:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518558#M3576</link>
      <description>&lt;P&gt;Show us the SAS log as I described earlier.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 20:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518558#M3576</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-04T20:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518561#M3577</link>
      <description>&lt;P&gt;This is the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;660 options mprint;&lt;BR /&gt;661 %macro one(x) (where=(wrat_raw not in (888 999)));&lt;BR /&gt;ERROR: Expected semicolon not found. The macro will not be compiled.&lt;BR /&gt;ERROR: A dummy macro will be compiled.&lt;BR /&gt;662 proc means n mean std median min max maxdec=1;&lt;BR /&gt;663 var &amp;amp;x;&lt;BR /&gt;664 class site_id Phase visit_id;&lt;BR /&gt;665 run;&lt;BR /&gt;666 %mend one;&lt;BR /&gt;667 %one (wrat_raw);&lt;BR /&gt;NOTE: Line generated by the invoked macro "ONE".&lt;BR /&gt;1 proc means (where=(wrat_raw not in (888 999))) n mean std median min max maxdec=1;&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;MPRINT(ONE): proc means (where=(wrat_raw not in (888 999))) n mean std median min max maxdec=1;&lt;BR /&gt;MPRINT(ONE): var wrat_raw;&lt;BR /&gt;ERROR: No data set open to look up variables.&lt;BR /&gt;ERROR: No data set open to look up variables.&lt;BR /&gt;ERROR: No data set open to look up variables.&lt;BR /&gt;MPRINT(ONE): class site_id Phase visit_id;&lt;BR /&gt;ERROR: No data set open to look up variables.&lt;BR /&gt;MPRINT(ONE): run;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ALPHA, CHARTYPE, CLASSDATA, CLM,&lt;BR /&gt;COMPLETETYPES, CSS, CV, DATA, DESCEND, DESCENDING, DESCENDTYPES, EXCLNPWGT,&lt;BR /&gt;EXCLNPWGTS, EXCLUSIVE, FW, IDMIN, KURTOSIS, LCLM, MAX, MAXDEC, MEAN, MEDIAN, MIN,&lt;BR /&gt;MISSING, MODE, N, NDEC, NMISS, NOLABELS, NONOBS, NOPRINT, NOTHREADS, NOTRAP, NWAY,&lt;BR /&gt;ORDER, P1, P10, P20, P25, P30, P40, P5, P50, P60, P70, P75, P80, P90, P95, P99,&lt;BR /&gt;PCTLDEF, PRINT, PRINTALL, PRINTALLTYPES, PRINTIDS, PRINTIDVARS, PROBT, Q1, Q3,&lt;BR /&gt;QMARKERS, QMETHOD, QNTLDEF, QRANGE, RANGE, SKEWNESS, STACKODS, STACKODSOUTPUT,&lt;BR /&gt;STDDEV, STDERR, SUM, SUMSIZE, SUMWGT, T, THREADS, UCLM, USS, VAR, VARDEF.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 20:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518561#M3577</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-12-04T20:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518569#M3581</link>
      <description>&lt;P&gt;Please, in the future, click on the {i} icon and paste your log into that window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;660 options mprint;
661 %macro one(x) (where=(wrat_raw not in (888 999)));
ERROR: Expected semicolon not found. The macro will not be compiled.&lt;/PRE&gt;
&lt;P&gt;You are missing a semi-colon, according to the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It probably should begin something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro one(x);
proc means data=datasetname(where=(wrat_raw not in (888 999)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But let's take a step back. Do you know that PROC MEANS can work on many variables at one time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=datasetname;
    var wrat_raw wrat_ss wrat_perc;
...
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and now there's no need for a macro at all.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 20:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518569#M3581</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-04T20:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with macro with where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518613#M3593</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140136"&gt;@Denali&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried the below code, but 888 still shows up as the maximum value.&amp;nbsp;&lt;BR /&gt;proc means data=nero2 (where=(wrat_raw ne 888 or wrat_raw ne 999)) mean std median min max maxdec=1;&lt;BR /&gt;class site_id Phase visit_id;&lt;BR /&gt;var wrat_raw;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Basic logic. You have coded something like this:&lt;/P&gt;
&lt;P&gt;(A ne&amp;nbsp;X) or (A ne Y )&lt;/P&gt;
&lt;P&gt;When X is different than Y the condition is always true. If A = x then A is NOT = Y and the inverse as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to do the data cleaning step in the beginning? 888 and 999 are both missing value, how do I define them as '.'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If var = somevalue then var=.;&lt;/P&gt;
&lt;P&gt;or special missing:&lt;/P&gt;
&lt;P&gt;if var = somevalue then var = .A;&amp;nbsp; (.A through .Z are available as well as ._) These numeric values are missing so excluded from calculations but can be examined to see something about the original value or displayed with a custom format for each special missing value such as "Refused to answer" "Not Asked" "Not Answered" "Biologically Implausible" or similar as wanted.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 00:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-with-macro-with-where-statement/m-p/518613#M3593</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-05T00:24:41Z</dc:date>
    </item>
  </channel>
</rss>

