<?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: create array from comma delimited text string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41258#M8439</link>
    <description>I'm going to rephrase my question it's more of a conceptual question. &lt;BR /&gt;
&lt;BR /&gt;
I have a variable whose value is a comma delimited text string. The text string itself it is a series of values. The number of values in the text string varies from record to record. The number of values in each text string is identified by another variable mxcnt, (mxcnt -1) has been defined as the the number of values in the text string. &lt;BR /&gt;
&lt;BR /&gt;
Ultimately I will want to use these values 3,5,7 to refer to a variable in another table(single vector of b1 variables and their relative values)namely b3,b5,b7 and return the value of the respective b variable.&lt;BR /&gt;
&lt;BR /&gt;
What is the best approach, if in the long run I'm using the values to reference variables in another table.</description>
    <pubDate>Fri, 05 Jun 2009 04:35:13 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-06-05T04:35:13Z</dc:date>
    <item>
      <title>create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41253#M8434</link>
      <description>I have a variable whose values are a comma delimited text string:&lt;BR /&gt;
&lt;BR /&gt;
Var1&lt;BR /&gt;
3,5&lt;BR /&gt;
4,7,9,11&lt;BR /&gt;
15,17,19,21,23&lt;BR /&gt;
&lt;BR /&gt;
Each value in the text string represents an associated beta value in another sas data set. So 3,5 represents B3 &amp;amp; B5 found in dataset PARMS. I need a method of &lt;BR /&gt;
&lt;BR /&gt;
a) parsing through the values in the string (I chose an array)&lt;BR /&gt;
b) then associating those values with the beta values in another dataset&lt;BR /&gt;
(I was thinking an array of macro variables)&lt;BR /&gt;
&lt;BR /&gt;
The structure of the beta data set includes a beta variable for every B(i), e.g. B1=value B2=value. It is a single row of data. There are currently a few additional columns that include _TYPE_, etc.&lt;BR /&gt;
&lt;BR /&gt;
Since I want to refer to the value of each B(i) I thought an array of macro variables would do the trick. I could use some assistance and suggestions w.r.t creating the array of string values....but am more in need of assistance w.r.t. referencing actual values of B(i), how and when do I call them.&lt;BR /&gt;
&lt;BR /&gt;
Am I doing something in multiple steps that can be accomplished going directly from list to beta value....I think the macro array is necessary but would like confirmation.</description>
      <pubDate>Thu, 04 Jun 2009 20:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41253#M8434</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-04T20:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41254#M8435</link>
      <description>A DATA step approach to parse out the input, creating some max number of B1 through Bnn SAS variables (not macro).  Suggest calling these variable some different prefix, so that you can correlate them back to the Bnn variables in your beta dataset.  Parsing can use DO UNTIL(&lt;VAR&gt; = ' ');  END;  or some DO / END technique, keeping track of the max suffix value thus far (as a RETAIN variable since you have multiple input records).&lt;BR /&gt;
&lt;BR /&gt;
Sounds like a straightforward SAS (non macro language) task to me, however you might benefit from a macro variable to set the maximum SAS Bnn or new_Bnn var suffix (the "nn" portion).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/VAR&gt;</description>
      <pubDate>Thu, 04 Jun 2009 20:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41254#M8435</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-04T20:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41255#M8436</link>
      <description>Something like this maybe.... but I don't see how to accomplish the sequential variable names without a macro, the number will vary by group so I don't want to explicitly list them. What am I missing?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
 data altbs;&lt;BR /&gt;
  set altbs;&lt;BR /&gt;
  by ists tosts;&lt;BR /&gt;
  do i=1 to 5;&lt;BR /&gt;
    do until (last.ists);&lt;BR /&gt;
	 do until (last.tsts);&lt;BR /&gt;
	  do while n &amp;lt; maxcnt;&lt;BR /&gt;
	    **this is where I'm stuck where abeta(n) is abeta1 - abeta(maxcnt -1); &lt;BR /&gt;
		abetan=scan(altb,n,',');&lt;BR /&gt;
      end;&lt;BR /&gt;
     end;&lt;BR /&gt;
	end;&lt;BR /&gt;
  end;&lt;BR /&gt;
  run;</description>
      <pubDate>Thu, 04 Jun 2009 22:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41255#M8436</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-04T22:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41256#M8437</link>
      <description>One step at a time -- pre-parse your incoming data and set a max var suffix using CALL SYMPUT.  You're going to have to take it from this point.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 05 Jun 2009 02:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41256#M8437</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-05T02:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41257#M8438</link>
      <description>This is my incoming data &lt;BR /&gt;
&lt;BR /&gt;
       Var1&lt;BR /&gt;
obs 3,5&lt;BR /&gt;
obs 4,7,9,11&lt;BR /&gt;
obs 15,17,19,21,23&lt;BR /&gt;
&lt;BR /&gt;
Can anyone provide some more details. I don't know what to do with the suggestion.</description>
      <pubDate>Fri, 05 Jun 2009 04:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41257#M8438</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-05T04:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41258#M8439</link>
      <description>I'm going to rephrase my question it's more of a conceptual question. &lt;BR /&gt;
&lt;BR /&gt;
I have a variable whose value is a comma delimited text string. The text string itself it is a series of values. The number of values in the text string varies from record to record. The number of values in each text string is identified by another variable mxcnt, (mxcnt -1) has been defined as the the number of values in the text string. &lt;BR /&gt;
&lt;BR /&gt;
Ultimately I will want to use these values 3,5,7 to refer to a variable in another table(single vector of b1 variables and their relative values)namely b3,b5,b7 and return the value of the respective b variable.&lt;BR /&gt;
&lt;BR /&gt;
What is the best approach, if in the long run I'm using the values to reference variables in another table.</description>
      <pubDate>Fri, 05 Jun 2009 04:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41258#M8439</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-05T04:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41259#M8440</link>
      <description>design&lt;BR /&gt;
you have run-time information in a variable (in I presume, more than one row) of a data-set. So, why try to solve the lookup with compile-time information like macro variables?&lt;BR /&gt;
The classic solutions would be either an indexed set statement, or an informat lookup (well, you have a string and want the corresponding numeric value from another table). &lt;BR /&gt;
Since SAS9 the new alternative to consider is a hash table lookup. Over formats and informats, hash tables have the advantage of indexing on multiple keys and can return more than one value, and all these keys and data can be of mixed data-types.&lt;BR /&gt;
Each of these alternative techniques will feature among the Samples you'll find searchable in the &lt;A href="http://support.sas.com" target="_blank"&gt;http://support.sas.com&lt;/A&gt; site.&lt;BR /&gt;
Good luck as you discover the wealth of ideas provided there.&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Fri, 05 Jun 2009 18:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41259#M8440</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-06-05T18:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: create array from comma delimited text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41260#M8441</link>
      <description>Also useful: function VVALUEX allows you to look up another variable's value whose name you derive on the fly.</description>
      <pubDate>Mon, 08 Jun 2009 01:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-array-from-comma-delimited-text-string/m-p/41260#M8441</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-06-08T01:29:06Z</dc:date>
    </item>
  </channel>
</rss>

