<?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: functions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245450#M45808</link>
    <description>&lt;P&gt;How do you like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test(drop=str);
str="We do not need to specify the length of a character variable if we are happy with the length it is given automatically";
do _n_=1 by 1 until(new=str);
  new=catx(' ',new,scan(str,_n_));
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Interestingly, variable NEW seems to inherit the type and length of STR because of the UNTIL condition. Without that, it would&amp;nbsp;be created as a &lt;EM&gt;numeric&lt;/EM&gt; variable because of its uninitialized occurrence in the second argument of CATX. If it didn't occur there either, it would get a default length of $200&amp;nbsp;(see&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl//en/lefunctionsref/67960/HTML/default/n0p7wxtk0hvn83n1pveisbcp2ae9.htm" target="_blank"&gt;documentation of the CATX function&lt;/A&gt;).&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jan 2016 15:06:41 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-01-22T15:06:41Z</dc:date>
    <item>
      <title>functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245408#M45791</link>
      <description>&lt;P&gt;program to disply sentance with n words as below in dataset variable ?&lt;/P&gt;&lt;P&gt;this&lt;BR /&gt;this is&lt;BR /&gt;this is sas&lt;BR /&gt;this is sas class.................n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 12:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245408#M45791</guid>
      <dc:creator>sonuvarsha</dc:creator>
      <dc:date>2016-01-22T12:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245410#M45792</link>
      <description>&lt;P&gt;Could you PLEASE be a little more elaborate about what you want to achieve?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 10:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245410#M45792</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-22T10:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245411#M45793</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the sentance r else you dont know the length of the sentance ...the words should display as 1st ,1st 2nd,1st 2nd 3rd ...........n&lt;/P&gt;&lt;P&gt;in a dataset with new variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;example &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;x='this is sas class'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;the output should be like &amp;nbsp;below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;new&lt;/P&gt;&lt;P&gt;______&lt;/P&gt;&lt;P&gt;this&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is sas&lt;/P&gt;&lt;P&gt;this is sas class&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 10:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245411#M45793</guid>
      <dc:creator>sonuvarsha</dc:creator>
      <dc:date>2016-01-22T10:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245413#M45794</link>
      <description>&lt;P&gt;One way for that&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data null;
length x $20;
retain x " ";
str="this is sas class";
do i = 1 to COUNTW(str) by 1;
   	x= strip(x) || " "||scan(str,i,' ') ;
   	output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jan 2016 10:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245413#M45794</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-22T10:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245415#M45795</link>
      <description>&lt;P&gt;can we write the same program using other functions like anyspace , substr, compress,find &amp;nbsp;functions ?n length shuld be the default &amp;nbsp;length of the string to the new variable&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 10:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245415#M45795</guid>
      <dc:creator>sonuvarsha</dc:creator>
      <dc:date>2016-01-22T10:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245422#M45799</link>
      <description>&lt;P&gt;Maybe we could, but why would we want to?&lt;/P&gt;
&lt;P&gt;Mohamed's solution is looking fine, mine would have been almost identical.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 11:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245422#M45799</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-22T11:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245430#M45800</link>
      <description>&lt;P&gt;because everytime we have to write length statement before if we increase that string word count......if string length is unkown then ??? that is my question&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 12:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245430#M45800</guid>
      <dc:creator>sonuvarsha</dc:creator>
      <dc:date>2016-01-22T12:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245431#M45801</link>
      <description>&lt;P&gt;Setting the length is necessary. If you need to automate that, you can read the length of the input variable beforehand from sashelp.vcolumn and use that to set the length in the final data step.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 12:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245431#M45801</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-22T12:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245450#M45808</link>
      <description>&lt;P&gt;How do you like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test(drop=str);
str="We do not need to specify the length of a character variable if we are happy with the length it is given automatically";
do _n_=1 by 1 until(new=str);
  new=catx(' ',new,scan(str,_n_));
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Interestingly, variable NEW seems to inherit the type and length of STR because of the UNTIL condition. Without that, it would&amp;nbsp;be created as a &lt;EM&gt;numeric&lt;/EM&gt; variable because of its uninitialized occurrence in the second argument of CATX. If it didn't occur there either, it would get a default length of $200&amp;nbsp;(see&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl//en/lefunctionsref/67960/HTML/default/n0p7wxtk0hvn83n1pveisbcp2ae9.htm" target="_blank"&gt;documentation of the CATX function&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2016 15:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245450#M45808</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-22T15:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245477#M45815</link>
      <description>&lt;P&gt;This would work too&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;;
str="this is sas class";
x=str;
do i = 1 to COUNTW(str) by 1;
	if i=1 then x="";
   	x= strip(x) || " "||scan(str,i,' ') ;
   	output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jan 2016 16:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/functions/m-p/245477#M45815</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-22T16:17:00Z</dc:date>
    </item>
  </channel>
</rss>

