<?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: user here with a FIRST.var &amp;amp; LAST.var question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469349#M120043</link>
    <description>thank you for quick reply.was looking for what pgstats suggested.&lt;BR /&gt;&lt;BR /&gt;cheers,</description>
    <pubDate>Mon, 11 Jun 2018 18:15:43 GMT</pubDate>
    <dc:creator>himalayancat</dc:creator>
    <dc:date>2018-06-11T18:15:43Z</dc:date>
    <item>
      <title>user here with a FIRST.var &amp; LAST.var question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469320#M120031</link>
      <description>&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am aware little how first.var and last.var works but i want to assign value to all the var that are not in first.var and last.var but not able.&lt;/P&gt;&lt;P&gt;your help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data need;&lt;BR /&gt;format this;&lt;BR /&gt;set have;&lt;BR /&gt;by sex;&lt;/P&gt;&lt;P&gt;if first.sex then do;&lt;BR /&gt;this='first';&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;if not&lt;BR /&gt;first.sex and last.sex then do;&lt;BR /&gt;this='in_betwn';&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;if last.sex then do;&lt;BR /&gt;this='last';&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* */&lt;BR /&gt;/* if UPCASE(sex) NE ('F') THEN DO; */&lt;BR /&gt;/* YY='ZZ'; */&lt;BR /&gt;/* END; */&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 17:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469320#M120031</guid>
      <dc:creator>himalayancat</dc:creator>
      <dc:date>2018-06-11T17:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: user here with a FIRST.var &amp; LAST.var question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469325#M120033</link>
      <description>&lt;P&gt;Two easy issues here ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, you need to set a length for your new variable.&amp;nbsp; Otherwise it takes its length from "first" and won't be long enough to hold "in_betwn":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;length this $ 8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, NOT applies to just one condition.&amp;nbsp; To get it to apply to both, add parentheses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if not&lt;BR /&gt;(first.sex &lt;FONT color="#ff0000"&gt;or&lt;/FONT&gt; last.sex) then do;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 17:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469325#M120033</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-11T17:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: user here with a FIRST.var &amp; LAST.var question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469326#M120034</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not first.sex and not last.sex then do;
this='in_betwn';
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 17:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469326#M120034</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-06-11T17:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: user here with a FIRST.var &amp; LAST.var question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469328#M120036</link>
      <description>&lt;P&gt;I get a "not valid file type" error attempting to open your pdf.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the "problem" is that in between values are showing as "in_be" then the issue is that you did not assign a length to the THIS variable and so SAS assigned a length of 5 because the first use of the variable is in:&amp;nbsp; This='first'; and "first" is 5 characters long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If "this" variable exists in your set Have data set and it has a length other than 5, or is numeric that could cause other issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is something else then show the results as text and likely show the log from running the code as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 17:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469328#M120036</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-11T17:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: user here with a FIRST.var &amp; LAST.var question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469342#M120041</link>
      <description>&lt;P&gt;Keep it simple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need;
set have; by sex;

length this $8;

if first.sex then this='first';
else if last.sex then this='last';
else this='in_betwn';

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 18:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469342#M120041</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-11T18:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: user here with a FIRST.var &amp; LAST.var question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469349#M120043</link>
      <description>thank you for quick reply.was looking for what pgstats suggested.&lt;BR /&gt;&lt;BR /&gt;cheers,</description>
      <pubDate>Mon, 11 Jun 2018 18:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/user-here-with-a-FIRST-var-amp-LAST-var-question/m-p/469349#M120043</guid>
      <dc:creator>himalayancat</dc:creator>
      <dc:date>2018-06-11T18:15:43Z</dc:date>
    </item>
  </channel>
</rss>

