<?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: can i use between in if statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258434#M49773</link>
    <description>&lt;P&gt;Yes, that is no problem:&lt;/P&gt;
&lt;PRE&gt;data want;&lt;BR /&gt; do var1=1 to 20;&lt;BR /&gt;   var2=ifc(var1&amp;lt;=10,"First","Last");&lt;BR /&gt;   output;&lt;BR /&gt; end;&lt;BR /&gt;run;
&lt;/PRE&gt;
&lt;P&gt;Not sure why you think you would not be able to do that in a datastep?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Mar 2016 09:22:46 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-03-23T09:22:46Z</dc:date>
    <item>
      <title>can i use between in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258429#M49771</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a new variable for which i have var1 as 1 to 20.&lt;/P&gt;
&lt;P&gt;if var1 is 1 to 10 then create a new var as var2='first' and from 11 to 20 as var2='Last'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can i do this in datastep?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 09:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258429#M49771</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-03-23T09:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: can i use between in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258434#M49773</link>
      <description>&lt;P&gt;Yes, that is no problem:&lt;/P&gt;
&lt;PRE&gt;data want;&lt;BR /&gt; do var1=1 to 20;&lt;BR /&gt;   var2=ifc(var1&amp;lt;=10,"First","Last");&lt;BR /&gt;   output;&lt;BR /&gt; end;&lt;BR /&gt;run;
&lt;/PRE&gt;
&lt;P&gt;Not sure why you think you would not be able to do that in a datastep?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 09:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258434#M49773</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-23T09:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: can i use between in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258435#M49774</link>
      <description>&lt;P&gt;Yes, but this step is also doubling the obs.&lt;/P&gt;
&lt;P&gt;I want like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var1 &amp;nbsp; &amp;nbsp;var2&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;first&lt;/P&gt;
&lt;P&gt;102 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;first&lt;/P&gt;
&lt;P&gt;103 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;last &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 09:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258435#M49774</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-03-23T09:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: can i use between in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258438#M49777</link>
      <description>&lt;P&gt;No, it is not doubling the obs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id var1;
cards;
101 1
101 10
101 15
;
run;

title "Dataset HAVE";

proc print;
run;

data want;
set have;
var2=ifc(var1&amp;lt;=10,"First","Last");
run;

title "Dataset WANT";

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;gives this result:&lt;/P&gt;
&lt;PRE&gt;                                                            Dataset HAVE

                                                         Obs     id    var1

                                                          1     101      1 
                                                          2     101     10 
                                                          3     101     15 
                                                            Dataset WANT

                                                    Obs     id    var1    var2

                                                     1     101      1     First
                                                     2     101     10     First
                                                     3     101     15     Last 
&lt;/PRE&gt;
&lt;P&gt;You see, there are the same number of observations in both datasets.&lt;/P&gt;
&lt;P&gt;Maybe you need to be more specific with your requirements.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 09:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258438#M49777</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-03-23T09:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: can i use between in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258442#M49780</link>
      <description>&lt;P&gt;Your requirement states, and I quote:&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;I want to create a new variable for which i have var1 as 1 to 20."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Therefore your output dataset will have 20 observations, per my code. &amp;nbsp;If you requirements are not like, please clarify your problem, post test data - in the form of a datastep, and what the output should look like.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 09:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258442#M49780</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-23T09:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: can i use between in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258477#M49802</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see. You "&lt;SPAN&gt;want to create a new variable" &lt;STRONG&gt;in an existing dataset&lt;/STRONG&gt; "for which [you] have var1 as 1 to 20."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether you really need a new variable (with redundant information!) depends on what you plan to do with it. Maybe it's sufficient to create a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value grp
 1-10 = 'first'
11-20 = 'last';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can do many things with your existing VAR1 together with this format. For example, perform a frequency count:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
format var1 grp.;
tables var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really need the new variable, you can still create it using the format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
var2=put(var1, grp.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 12:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-i-use-between-in-if-statement/m-p/258477#M49802</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-23T12:26:18Z</dc:date>
    </item>
  </channel>
</rss>

