<?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 Why nobs = n and not n = nobs? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843401#M333441</link>
    <description>&lt;P&gt;Hi -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a long time SAS user but there are still some things I don't understand. When using nobs to count observations, as in&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;BR /&gt;&amp;nbsp;if 0 then set sashelp.cars &lt;STRONG&gt;nobs=n&lt;/STRONG&gt;;&lt;BR /&gt;put "no. of observations =" n;&lt;BR /&gt;&amp;nbsp;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why is the syntax "nobs = n" instead of "n = nobs"? Any other time we want to create a new variable, we put the name of the variable on the left of the equal sign and the value on the right. Here it's the opposite. Can someone explain this to me?&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2022 16:09:30 GMT</pubDate>
    <dc:creator>Bison370</dc:creator>
    <dc:date>2022-11-09T16:09:30Z</dc:date>
    <item>
      <title>Why nobs = n and not n = nobs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843401#M333441</link>
      <description>&lt;P&gt;Hi -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a long time SAS user but there are still some things I don't understand. When using nobs to count observations, as in&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;BR /&gt;&amp;nbsp;if 0 then set sashelp.cars &lt;STRONG&gt;nobs=n&lt;/STRONG&gt;;&lt;BR /&gt;put "no. of observations =" n;&lt;BR /&gt;&amp;nbsp;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why is the syntax "nobs = n" instead of "n = nobs"? Any other time we want to create a new variable, we put the name of the variable on the left of the equal sign and the value on the right. Here it's the opposite. Can someone explain this to me?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 16:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843401#M333441</guid>
      <dc:creator>Bison370</dc:creator>
      <dc:date>2022-11-09T16:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why nobs = n and not n = nobs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843404#M333442</link>
      <description>&lt;P&gt;The option in the SET command is NOBS=variablename. This is consistent with the way other options in the SET command work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you type&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 0 then set sashelp.cars n = nobs;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you get an error, as there is no option in the SET command that is N=&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 16:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843404#M333442</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-09T16:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why nobs = n and not n = nobs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843406#M333444</link>
      <description>&lt;P&gt;You are confusing two totally different things. Both of which are common things to do in SAS.&lt;/P&gt;
&lt;P&gt;In this statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set sashelp.cars nobs=n;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOBS is the name of an option that the SET statement supports.&amp;nbsp; The equal sign separates the option name from the value being given for the option.&amp;nbsp; This particular option wants the NAME of a variable.&amp;nbsp; It will then populate that variable with the number of observations in the dataset.&lt;/P&gt;
&lt;P&gt;These statements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;nobs=n;
n=nobs;
z=y+x;
index=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are assignment statements.&amp;nbsp; The are used in data steps (and some PROCs that support coding).&lt;/P&gt;
&lt;P&gt;The name of the variable that is being assigned the value comes first.&amp;nbsp; The equal sign indicates that is an assignment statement.&amp;nbsp; And everything after the equal sign is the expression that resolves to the value to be assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 16:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843406#M333444</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-09T16:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why nobs = n and not n = nobs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843414#M333448</link>
      <description>&lt;P&gt;Thank you! This makes sense.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 16:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-nobs-n-and-not-n-nobs/m-p/843414#M333448</guid>
      <dc:creator>Bison370</dc:creator>
      <dc:date>2022-11-09T16:35:22Z</dc:date>
    </item>
  </channel>
</rss>

