<?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 Proper format to write the code and the output in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proper-format-to-write-the-code-and-the-output/m-p/847270#M36937</link>
    <description>&lt;P&gt;Table a&lt;/P&gt;&lt;P&gt;x=10&lt;/P&gt;&lt;P&gt;y=25&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data b;&lt;/P&gt;&lt;P&gt;set a;&lt;/P&gt;&lt;P&gt;z=x+y&lt;/P&gt;&lt;P&gt;wherez&amp;gt;30 then output;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 15:49:20 GMT</pubDate>
    <dc:creator>animesh123</dc:creator>
    <dc:date>2022-12-01T15:49:20Z</dc:date>
    <item>
      <title>Proper format to write the code and the output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proper-format-to-write-the-code-and-the-output/m-p/847270#M36937</link>
      <description>&lt;P&gt;Table a&lt;/P&gt;&lt;P&gt;x=10&lt;/P&gt;&lt;P&gt;y=25&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data b;&lt;/P&gt;&lt;P&gt;set a;&lt;/P&gt;&lt;P&gt;z=x+y&lt;/P&gt;&lt;P&gt;wherez&amp;gt;30 then output;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 15:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proper-format-to-write-the-code-and-the-output/m-p/847270#M36937</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-01T15:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proper format to write the code and the output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proper-format-to-write-the-code-and-the-output/m-p/847281#M36938</link>
      <description>&lt;P&gt;SAS Where statement in a data step requires reference to values in data sets on the SET statement. So "where z" is not valid. Also WHERE does not use "then" in any form. The purpose of where is selection of records so specifically a "then output" would be redundant.&lt;/P&gt;
&lt;P&gt;You could use to select records such that x+y is &amp;gt; 30 if you really want to use where.&lt;/P&gt;
&lt;PRE&gt;Data b;
  set a;
  where (x+y)&amp;gt;30;
run;&lt;/PRE&gt;
&lt;P&gt;If you need the variable z you would have to create it.&lt;/P&gt;
&lt;P&gt;Or use an IF. This is a "sub-setting if"&lt;/P&gt;
&lt;PRE&gt;data b2;
  set a;
  z= x+y;
  if z&amp;gt;30;
run;&lt;/PRE&gt;
&lt;P&gt;The only observations processed after the IF will be those where the If is true. So the implied output at the end of the data step makes this equivalent to&lt;/P&gt;
&lt;PRE&gt;data b2;
  set a;
  z= x+y;
  if z&amp;gt;30 then output;
run;&lt;/PRE&gt;
&lt;P&gt;Hint:&lt;/P&gt;
&lt;P&gt;Provide your example data in the from of a working data step such as:&lt;/P&gt;
&lt;PRE&gt;data a;
   input x y;
   datalines;
10 25
;&lt;/PRE&gt;
&lt;P&gt;multiple lines of x y values in the datalines would allow testing more values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430763"&gt;@animesh123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Table a&lt;/P&gt;
&lt;P&gt;x=10&lt;/P&gt;
&lt;P&gt;y=25&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data b;&lt;/P&gt;
&lt;P&gt;set a;&lt;/P&gt;
&lt;P&gt;z=x+y&lt;/P&gt;
&lt;P&gt;wherez&amp;gt;30 then output;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 20:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proper-format-to-write-the-code-and-the-output/m-p/847281#M36938</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-01T20:45:05Z</dc:date>
    </item>
  </channel>
</rss>

