<?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: scan function with only spaces as delimiter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278963#M56181</link>
    <description>&lt;P&gt;What is the full code your running, can't see from this snippet. &amp;nbsp;However in your second code:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'w_gamma_2 1-w_alpha_1'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You mention a variable i which isn't in the first set of code. &amp;nbsp;Normally:&lt;/P&gt;
&lt;PRE&gt;data want;
  result=scan('w_gamma_2 1-w_alpha1',1,' ');
run;
&lt;/PRE&gt;
&lt;P&gt;Should work fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jun 2016 10:03:55 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-06-21T10:03:55Z</dc:date>
    <item>
      <title>scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278959#M56178</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to use the scan function with only spaces as delimiter&lt;/P&gt;
&lt;P&gt;because when I don't specify delimiters, a dash is also interpreted as a delimiter.&lt;/P&gt;
&lt;P&gt;For example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;scan('w_gamma_2 1-w_alpha_1',1) --&amp;gt; w_gamma_2
scan('w_gamma_2 1-w_alpha_1',2) --&amp;gt; 1
scan('w_gamma_2 1-w_alpha_1',3) --&amp;gt; w_alpha_1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I need to get `w_gamma_2` and `1-w_alpha_1`, not split by the dash&lt;/P&gt;
&lt;P&gt;I tried these 3 things:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;scan('w_gamma_2 1-w_alpha_1',i,' ')
scan('w_gamma_2 1-w_alpha_1',i,%str(' '))
scan('w_gamma_2 1-w_alpha_1',i,'',s)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but all 3 make all my enterprise guide session completely crash&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3691i1ECF33022E9F8ECB/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Image 8.png" title="Image 8.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt; An error occurred executing the workspace job "xxxxxx". &lt;BR /&gt;&amp;gt; The server is disconnected&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Deleting all my tables in the WORK library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas on what is wrong here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm in a data step &lt;BR /&gt;I'm using Enterprise Guide 7.1 and SAS 9.3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 09:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278959#M56178</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2016-06-21T09:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278963#M56181</link>
      <description>&lt;P&gt;What is the full code your running, can't see from this snippet. &amp;nbsp;However in your second code:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'w_gamma_2 1-w_alpha_1'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You mention a variable i which isn't in the first set of code. &amp;nbsp;Normally:&lt;/P&gt;
&lt;PRE&gt;data want;
  result=scan('w_gamma_2 1-w_alpha1',1,' ');
run;
&lt;/PRE&gt;
&lt;P&gt;Should work fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 10:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278963#M56181</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-21T10:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278964#M56182</link>
      <description>&lt;P&gt;i&amp;nbsp;=&amp;nbsp;1, 2, 3... from a&amp;nbsp;do&amp;nbsp;iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you think the scan(,,' ')&amp;nbsp;should be fine&lt;/P&gt;
&lt;P&gt;then the crash may be caused by the rest of the code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is&amp;nbsp;the whole data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data PROPORTIONED;

	length
		Germ $10
		Year 3
		AgeGroupDALY $10 
		AgeGroupSPMA $10 
		Gender $1
		State $99
		Category1 $50 
		Category2 $50 
		value 8 
		;

	*** make link to hash table ;
	if _n_=1 then do;

		***modelvalues ----------------;
		declare hash h1(dataset:'modelData');
		h1.definekey ('Germ', 'Category1', 'Category2', 'AgeGroupDALY', 'Gender') ;
		h1.definedata('Value');
		h1.definedone();
		call missing(Germ, Value, Category1, Category2);
		* e.g. rc=h1.find(KEY:Germ, KEY:"State", KEY:"property", KEY:AgeGroupDALY, KEY:Gender);

	end;

	set EDGED;
	put "°°°°° _n_=" _n_;


	put "Germ=" Germ;
	edgesList=tranwrd(edgesList,'||',' ');
	put "edgesList=" edgesList;

	Probability=1;
	*ProbabilitiesList = '++++';

	do i=1 to countw(edgesList);
		put "- i=" i;
		*Edge = scan(edgesList,i,' '); * --&amp;gt; crash ;
		*Edge = scan(edgesList,i,%str(' ')); * --&amp;gt; crash ;
		*Edge = scan(edgesList,i,'',s); * --&amp;gt; crash ;
		Edge = scan(edgesList,i); * --&amp;gt; no crash ;
		put "edge=" Edge;


		* deal with trans probabilities;
		*if find(edge,'1-','i') ge 1 then do;
		if Edge =: '1-' then do;
			put 'i trans probability';
			edge=tranwrd(edge,'-1','');
			marker=1;
			put "edge=" Edge;
		end;

		*lookup;
		rc=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:AgeGroupDALY, KEY:Gender);

		if marker=1 then do;
			value = 1 - value;
		end;
		
		*IF lookup fail;
		if rc ^= 0 then do;
			*rc=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:AgeGroupDALY, KEY:Gender);
			value = 777777;
		end;
		if value = . then do;
			*rc=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:AgeGroupDALY, KEY:Gender);
			value = 666666;
		end;

		Probability = Probability * value;
		put "value=" value;
		put "Probability=" Probability;
		*ProbabilitiesList = tranwrd(ProbabilitiesList,'+','--');
	end;


	Proportion = Probability;

	DALY = Cases * Duration * Severity * Proportion;
	DALYperCase = Duration * Severity * Proportion;

	drop Probability rc i Edge Category1 Category2 Value;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 10:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278964#M56182</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2016-06-21T10:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278965#M56183</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok, you are using Hash Tables, I have never found a need to use it so can't help further on that. &amp;nbsp;Could be any number of things from system resources etc. &amp;nbsp;All I can say is the scan statement is correct:&lt;/P&gt;
&lt;PRE&gt;data want;
  result=scan('w_gamma_2 1-w_alpha1',1,' ');
run;&lt;/PRE&gt;
&lt;P&gt;How that interacts with Hash Tables&amp;nbsp;I can't say. &amp;nbsp;Try doing the code using Base SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Not IML, Hash Tables. &amp;nbsp;Again, never found a need for them, so not used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 10:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278965#M56183</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-21T10:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278966#M56184</link>
      <description>&lt;P&gt;May I ask where&amp;nbsp;I'm using IML?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think I have SAS/IML and I'm not aware I never used it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 10:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278966#M56184</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2016-06-21T10:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278967#M56185</link>
      <description>&lt;P&gt;See edit, I meant Has Tables.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 10:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278967#M56185</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-21T10:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278969#M56186</link>
      <description>&lt;P&gt;If you use countw() to determine the number of "words" in your string, you must supply the same list of delimiters that you use in the scan() function, or it will give you a higher number of "words" than are present in the string.&lt;/P&gt;
&lt;P&gt;Depending on your settings, this might produce enough log messages so that you run out of memory (which is already under stress due to the hash object) or something else that crashes your server session.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 10:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278969#M56186</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-21T10:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278974#M56189</link>
      <description>&lt;P&gt;I'm solving the scan problem by using '_1_' instead of '1-'.&lt;/P&gt;
&lt;P&gt;With this, no need to change the countw and the scan anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I agree with the memory&amp;nbsp;issue&lt;/P&gt;
&lt;P&gt;I got the error again and after commenting&amp;nbsp;all the put statements it runs better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 11:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/278974#M56189</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2016-06-21T11:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/279304#M56277</link>
      <description>&lt;P&gt;Does someone know how can I &amp;nbsp;solve this memory problem ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because my table&amp;nbsp;is getting&amp;nbsp;10k times bigger and it already is crashing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did look at my computers RAM and CPU -&amp;gt; no spikes before the crash and much available&lt;/P&gt;
&lt;P&gt;I also looked and the BI server's RAM and CPU --&amp;gt; no spikes before the crash &lt;SPAN&gt;and much available&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I diagnose the crash ?&lt;/P&gt;
&lt;P&gt;Is there a parameter in SAS or EG to increase allocated memmory?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or maybe there is huge file being created on the disks somwhere?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 12:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/279304#M56277</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2016-06-22T12:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: scan function with only spaces as delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/279541#M56344</link>
      <description>&lt;P&gt;I'd try to specify logging into a file with logparms write=immediate. You will have to play around with the server's config files for this.&lt;/P&gt;
&lt;P&gt;You can also locate your current work directory in the filesystem and look for files that grow excessively.&lt;/P&gt;
&lt;P&gt;Are you sure you have removed all causes for unnecessary log entries?&lt;/P&gt;
&lt;P&gt;And if the base file for the hash object grows, you will run out of memory sooner or later. Some things need to be solved with datasets only, as there only disk storage is the limit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 19:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-with-only-spaces-as-delimiter/m-p/279541#M56344</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-22T19:45:38Z</dc:date>
    </item>
  </channel>
</rss>

