<?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: how to read multiple numbers as separate values in the same variable in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460208#M24029</link>
    <description>&lt;P&gt;Can you please explain how and why you got the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1 should be the count of these numbers 1, 4, 8, 65, 89&lt;/P&gt;&lt;P&gt;V2 should be the count of these numbers 2, 3 6, 7,...&lt;/P&gt;</description>
    <pubDate>Fri, 04 May 2018 23:13:34 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-04T23:13:34Z</dc:date>
    <item>
      <title>how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460198#M24023</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello, and thank you in advance to those who will try to help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an excel file with a variable that contains numbers (range 0-120). Each cell can contain multiple numbers, and they are separated by a comma. E.g. 2,19,4,45,2,9....&lt;/P&gt;&lt;P&gt;For this variable, respondents can have&amp;nbsp;a missing value, or any number of numbers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2,19,4,45,2,9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;3, 34, 4&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;17, 3,67,88&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to read/import this variable so to&amp;nbsp;compute two new variables. The first variable is a&amp;nbsp;count of certain number, let's say "odd" numbers"; the second variable, "even" number. For instance, from the example above, I want to have these two new variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3 3&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;3 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is because &amp;lt;&lt;SPAN&gt;2,19,4,45,2,9&amp;gt; has three odd and three even numbers; &amp;lt;3, 34, 4&amp;gt; has one odd and two even numbers, etc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone&amp;nbsp;suggest how&amp;nbsp;I could achieve this in SAS?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Emanuele&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 22:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460198#M24023</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2018-05-04T22:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460200#M24024</link>
      <description>1. Import data as standard (PROC IMPORT)&lt;BR /&gt;2. Split out data into individual elements (COUNTW() and SCAN())&lt;BR /&gt;3. classify as odd/even  (MOD() function)&lt;BR /&gt;4. Summarize within a report (PROC FREQ)</description>
      <pubDate>Fri, 04 May 2018 22:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460200#M24024</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-04T22:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460201#M24025</link>
      <description>&lt;P&gt;I think that the following does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input fieldname $20.;
  cards;
2,19,4,45,2,9
3, 34, 4
9
17, 3,67,88 
;

data want (drop=i);
  set have;
  odd=0;
  even=0;
  do i=1 to countw(fieldname);
    if mod(scan(fieldname,i),2) then odd+1;
    else even+1;
  end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 22:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460201#M24025</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-04T22:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460203#M24026</link>
      <description>&lt;P&gt;Reeza, thank you for the incredibly fast response.&lt;/P&gt;&lt;P&gt;I am still a bit&amp;nbsp;lost, since I have never used either functions. If you could give me more details, I would really appreciate.&lt;/P&gt;&lt;P&gt;I understand if you cannot. &amp;nbsp;I attach the data file that I obtain after importing my data in sas, with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILENAME REFFILE '/folders/myfolders/Bergamo2018/testing ART reading.csv';&lt;BR /&gt;libname bergamo '/folders/myfolders/Bergamo2018/';&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE=REFFILE&lt;BR /&gt;DBMS=CSV&lt;BR /&gt;OUT=bergamo.IMPORT1;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC CONTENTS DATA=WORK.IMPORT1; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 23:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460203#M24026</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2018-05-04T23:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460204#M24027</link>
      <description>&lt;P&gt;Thank you Art297.&lt;/P&gt;&lt;P&gt;This doesn't quite do it. I need to create two new variables. For simplicity, in my first post in indicated that&amp;nbsp;V1 should be the count&amp;nbsp;of even numbers, and V2 the count of odd numbers in the original variable. In reality, It is a bit more complicated:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1 should be the count of these numbers 1, 4, 8, 65, 89&lt;/P&gt;&lt;P&gt;V2 should be the count of these numbers 2, 3 6, 7,...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it make sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 23:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460204#M24027</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2018-05-04T23:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460207#M24028</link>
      <description>&lt;P&gt;Not really! Unless you mean:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input fieldname $20.;
  cards;
2,19,4,45,2,9
3, 34, 4
9
17, 3,67,88 
;

data want (drop=i);
  set have;
  v1=0;
  v2=0;
  do i=1 to countw(fieldname);
    if scan(fieldname,i) in (1, 4, 8, 65, 89) then v1+1;
    else v2+1;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 23:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460207#M24028</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-04T23:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460208#M24029</link>
      <description>&lt;P&gt;Can you please explain how and why you got the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1 should be the count of these numbers 1, 4, 8, 65, 89&lt;/P&gt;&lt;P&gt;V2 should be the count of these numbers 2, 3 6, 7,...&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 23:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460208#M24029</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-04T23:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460209#M24030</link>
      <description>&lt;P&gt;This is PERFECT. I am truly amazed at your kindness, and competence!&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 23:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460209#M24030</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2018-05-04T23:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to read multiple numbers as separate values in the same variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460217#M24031</link>
      <description>&lt;P&gt;the numbers correspond to&amp;nbsp;choices participants in a study made, when presented with a list of 120 items. 60 belong to a category, the other 60 to another category. Because of poor programming of the study, the data came organized this way.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 May 2018 01:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-read-multiple-numbers-as-separate-values-in-the-same/m-p/460217#M24031</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2018-05-05T01:10:03Z</dc:date>
    </item>
  </channel>
</rss>

