<?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: Using SAS functions - in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309475#M66586</link>
    <description>&lt;P&gt;You can use function COUNTW (meaning: Count words) and then check and decide&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what to assign to the new variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if countw(names) &amp;gt; 2 then mid_name = scan(names,2);&lt;/P&gt;</description>
    <pubDate>Sat, 05 Nov 2016 06:22:23 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-11-05T06:22:23Z</dc:date>
    <item>
      <title>Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309458#M66569</link>
      <description>&lt;P&gt;Want to use variables &lt;STRONG&gt;first&lt;/STRONG&gt; and &lt;STRONG&gt;last&lt;/STRONG&gt;&amp;nbsp;names from my data set to compute name in the form &lt;STRONG&gt;first, one space, last&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want to call &lt;STRONG&gt;firstlast&lt;/STRONG&gt;&amp;nbsp;assigning length. Then using&amp;nbsp;&lt;STRONG&gt;strip&lt;/STRONG&gt; function.&lt;/P&gt;&lt;P&gt;Then i want to use name in the form &lt;STRONG&gt;last, a comma, one space, first.&lt;/STRONG&gt; Calling it &lt;STRONG&gt;lastfirst&lt;/STRONG&gt; and assigning appropriate length. and using strip function .&lt;/P&gt;&lt;P&gt;Data is :&lt;/P&gt;&lt;P&gt;obs &amp;nbsp; &amp;nbsp; &amp;nbsp;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;first &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; last&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; Rahul David Anand &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Rahul &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Anand&amp;nbsp;&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; David &amp;nbsp;Tel Merck &amp;nbsp; Boxer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;David &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Boxer&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; Jim &amp;nbsp;carney Ramsey &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jim &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Ramsey&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; George Uday Yale &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;George&amp;nbsp; &amp;nbsp; &amp;nbsp; Yale&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp; Frank &amp;nbsp;Bates &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Frank &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Bates&lt;BR /&gt;6 &amp;nbsp; &amp;nbsp;Stacy Mary kim &amp;nbsp;Coghlan &amp;nbsp; &amp;nbsp; &amp;nbsp; Stacy &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Coghlam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code which i am trying is not giving me accurate results :I would be grateful if anybody can assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;length firstlast $50 ;&lt;BR /&gt;firstlast=catx(' ',first,last);&lt;/P&gt;&lt;P&gt;first=strip(first);&lt;BR /&gt;last=strip(last);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;length lastfirst $50;&lt;BR /&gt;lastfirst=catx(' ',last,',',first);&lt;/P&gt;&lt;P&gt;first=strip(first);&lt;BR /&gt;last=strip(last);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 03:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309458#M66569</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T03:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309460#M66571</link>
      <description>&lt;P&gt;Look at SCAN and COUNTW functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last_index = countw(name);&lt;/P&gt;
&lt;P&gt;first = SCAN(name, 1);&lt;/P&gt;
&lt;P&gt;last = scan(name, last_index);&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 04:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309460#M66571</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-05T04:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309461#M66572</link>
      <description>&lt;P&gt;You're not using CATX properly. Review the documentation and the examples in the documentation. Post back if you can't get it working.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 04:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309461#M66572</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-05T04:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309463#M66574</link>
      <description>&lt;P&gt;What are your results and why do you think it is not accurate ?&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 04:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309463#M66574</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-05T04:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309464#M66575</link>
      <description>I asked a simple question. I know that i can read the documentation. Why you are replying like i am kid and don't know where to read and what to read. I just wanted help to get required results. I know every thing about scan and countw.And what you have suggested will never work.Let somebody else help me and you stay easy.Thanks</description>
      <pubDate>Sat, 05 Nov 2016 04:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309464#M66575</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T04:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309465#M66576</link>
      <description>Dear Shmuel ,&lt;BR /&gt;When i run the first code its seems ok , but when i run the second part - the log gives error in length ,&lt;BR /&gt;I have tried scan , but it doesnt work.</description>
      <pubDate>Sat, 05 Nov 2016 04:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309465#M66576</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T04:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309466#M66577</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113625"&gt;@afs&lt;/a&gt; wrote:&lt;BR /&gt;I asked a simple question. I know that i can read the documentation. Why you are replying like i am kid and don't know where to read and what to read. I just wanted help to get required results. I know every thing about scan and countw.And what you have suggested will never work.Let somebody else help me and you stay easy.Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I interpreted your question incorrectly, but your response is childish.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using ', ' as the first argument to CATX for your second step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck and good bye.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 04:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309466#M66577</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-05T04:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309467#M66578</link>
      <description>&lt;P&gt;You have not post your results and what error you have.&lt;/P&gt;
&lt;P&gt;I can't run your code now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the error message ? usually SAs messages are clear enough to overcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use an alternative code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;firstlast = strip(first} || ' ' || strip(last);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;lastfirst = strip(last) || ',' || strip(first);&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 05:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309467#M66578</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-05T05:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309468#M66579</link>
      <description>Dear Shmuel, When i write code as below as i need to define new variable firstlasta nd lastfirst , but log give error&lt;BR /&gt;&lt;BR /&gt;length firstlast $50 lastfirst $50;&lt;BR /&gt;firstlast = strip(first} || ' ' || strip(last);&lt;BR /&gt;lastfirst = strip(last) || ',' || strip(first);&lt;BR /&gt;run;&lt;BR /&gt;log error:&lt;BR /&gt;29 firstlast = strip(fitst} || ' ' || strip(last);&lt;BR /&gt;_______&lt;BR /&gt;180&lt;BR /&gt;&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;&lt;BR /&gt;30&lt;BR /&gt;31 lastfirst = strip(last) || ',' || strip(first);&lt;BR /&gt;_________&lt;BR /&gt;180</description>
      <pubDate>Sat, 05 Nov 2016 05:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309468#M66579</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T05:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309470#M66581</link>
      <description>&lt;P&gt;The message: &amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;Statement is not valid or it is used out of proper order.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;menas that code is out of proper order. It should be like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ... enter any code ...&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that you submitted lines without the first two lines ?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got the error - you used different brackets : &amp;nbsp;&lt;STRONG&gt;( } &amp;nbsp; &amp;nbsp; &amp;nbsp;instead &amp;nbsp;( )&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 05:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309470#M66581</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-05T05:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309471#M66582</link>
      <description>I actually found the error. The code you send had parenthesis error. That was a typing error. It worked. Actually, i was using the start lines , i was just sending you the main codes. Thanks for the help ...</description>
      <pubDate>Sat, 05 Nov 2016 05:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309471#M66582</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T05:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309472#M66583</link>
      <description>&lt;P&gt;your code should work too.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;was right:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;length lastfirst $50;&lt;BR /&gt;/* &amp;nbsp;lastfirst=catx(' ',last,',',first); &amp;lt;&amp;lt;&amp;lt; replace with next line */&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;lastfirst(',',last,first);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;first=strip(first);&lt;BR /&gt;last=strip(last);&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 05:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309472#M66583</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-05T05:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309473#M66584</link>
      <description>That was my working , he gave the following, and guided me to study from the documentation. His code did not work. And if someone wants to guide , he should not show attitude . I am head of a company,,,and just learning some new stuff so wanted guidance......I appreciate for your help...Still a long way to complete the codes ..Will get back if need help&lt;BR /&gt;&lt;BR /&gt;Look at SCAN and COUNTW functions.&lt;BR /&gt;&lt;BR /&gt;Last_index = countw(name);&lt;BR /&gt;first = SCAN(name, 1);&lt;BR /&gt;last = scan(name, last_index);</description>
      <pubDate>Sat, 05 Nov 2016 05:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309473#M66584</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T05:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309474#M66585</link>
      <description>&lt;P&gt;Dear Shmuel,&lt;/P&gt;&lt;P&gt;Just wanted to know if like in the data set there is a person who has 4 names and need to get his first middle name like David Tel Merck Boxer&amp;nbsp;so Tel is his middle name , and there are people who have only two names so no middle is there or we can say there would be blank. So i want to create a variable middle with length $25 .So is that also possible , ?&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 06:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309474#M66585</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T06:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309475#M66586</link>
      <description>&lt;P&gt;You can use function COUNTW (meaning: Count words) and then check and decide&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what to assign to the new variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if countw(names) &amp;gt; 2 then mid_name = scan(names,2);&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 06:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309475#M66586</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-05T06:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS functions -</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309476#M66587</link>
      <description>Yes it worked ..Thanks.... Actually i have done a lot of work in R ... But now want to be good in SAS .. R is good for visualization. But SAS is good in analytical...Thanks for getting my concepts strong</description>
      <pubDate>Sat, 05 Nov 2016 06:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-functions/m-p/309476#M66587</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-11-05T06:33:46Z</dc:date>
    </item>
  </channel>
</rss>

