<?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 csv files with some variabls delimited with bars into sas? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403580#M98070</link>
    <description>&lt;P&gt;Another questions, If&amp;nbsp; some ID&amp;nbsp;or candidates&amp;nbsp;did not answer all the questions, and they only have 4 questionid and 4 response, how to deal with that situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2017 14:59:36 GMT</pubDate>
    <dc:creator>daisy6</dc:creator>
    <dc:date>2017-10-12T14:59:36Z</dc:date>
    <item>
      <title>how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403566#M98065</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a csv file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp; &amp;nbsp; questionid&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;response&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;answerkey&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;grade&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp;q123|q234|q345|q456|q678|q789&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A|B|C|D|A|B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A|B|C|D|C|B&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;Pass&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the dataset like:&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;questionid&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; response&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; answerkey&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grade&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q123&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&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; &amp;nbsp; &amp;nbsp;A&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;Pass&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q234&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&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; &amp;nbsp; &amp;nbsp;B&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;Pass&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q345&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; C&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; &amp;nbsp; &amp;nbsp;C&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; Pass&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me out! I appreciate any help!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 14:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403566#M98065</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-10-12T14:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403568#M98066</link>
      <description>&lt;P&gt;You aren't showing where your commas may actually appear.&lt;/P&gt;
&lt;P&gt;Easiest would likely be to read the data as th3 5 variable you show then do something like this:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   do i=1 to ( countw(questionid,'|'));
      question = scan(questionid,i,'|');
      responsevalue = scan(response,i,'|');
      key  = scan(answerkey,i,'|');
  end;
  keep id question responsevalue key grade;
run;&lt;/PRE&gt;
&lt;P&gt;The new variables question, responsevalue and key are used instead of your existing variable names as doing something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;questioned= scan(questioned,1,'|'); would overwrite the existing value. OR you could rename the old variables on the set statement with dataset options and use the previous variable names if that is critical.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 14:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403568#M98066</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-12T14:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403569#M98067</link>
      <description>&lt;P&gt;Use the datastep&amp;nbsp;to import the data into SAS. A simple google seach will do the trick, tons of example thereof.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Onse it is there, do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Id$ questionid:$50. response:$20. answerkey:$20. grade$;
datalines;
123 q123|q234|q345|q456|q678|q789 A|B|C|D|A|B A|B|C|D|C|B Pass
;

data want(drop=i cnt questionid response answerkey);
   set have;
   cnt = countw(questionid, '|');
   i=1;
   do while(i &amp;lt; cnt);
      questionid_new = scan(questionid,i,'|');
      response_new = scan(response,i,'|');
      answerkey_new = scan(answerkey,i,'|');
      output;
      i = i+1;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 14:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403569#M98067</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-10-12T14:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403570#M98068</link>
      <description>&lt;P&gt;Think you would need an output statement before the end;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 14:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403570#M98068</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-12T14:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403571#M98069</link>
      <description>&lt;P&gt;I already import the CSV file into SAS. Your solutions are the exactly what I want! Thank you very much for prompt reply!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 14:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403571#M98069</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-10-12T14:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403580#M98070</link>
      <description>&lt;P&gt;Another questions, If&amp;nbsp; some ID&amp;nbsp;or candidates&amp;nbsp;did not answer all the questions, and they only have 4 questionid and 4 response, how to deal with that situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 14:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403580#M98070</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-10-12T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403588#M98073</link>
      <description>&lt;P&gt;Since I haven't seen your data I can't be sure, but I think the solutions above can handle that situation.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403588#M98073</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-10-12T15:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403594#M98074</link>
      <description>&lt;P&gt;I checked my data, and your code works perfectly!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403594#M98074</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-10-12T15:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403596#M98075</link>
      <description>&lt;P&gt;Two notes:&lt;/P&gt;
&lt;P&gt;Please mark the post of the person who supplied you the correct answer as Correct.&amp;nbsp; This both links the correct answer to the original post, and gives credit to the solution provider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, avoid closing one question and then starting another one in the same post - start a new topic.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403596#M98075</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-12T15:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403600#M98076</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148952"&gt;@daisy6&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Another questions, If&amp;nbsp; some ID&amp;nbsp;or candidates&amp;nbsp;did not answer all the questions, and they only have 4 questionid and 4 response, how to deal with that situation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This probably should be in a new topic, referencing this one, depending on what you mean by "deal with". In the new topic provide some examples of different types of incomplete data and what you want the result to look like for them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to go further than just the data set but to the report(s) you may be wanting, which is why a new topic is preferred.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403600#M98076</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-12T15:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403683#M98099</link>
      <description>&lt;P&gt;Got it! Thanks for the advice! Thanks for solved my problem Ballardw!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 20:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403683#M98099</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-10-12T20:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to read csv files with some variabls delimited with bars into sas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403684#M98100</link>
      <description>Thanks for the advice! RW9</description>
      <pubDate>Thu, 12 Oct 2017 20:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-csv-files-with-some-variabls-delimited-with-bars/m-p/403684#M98100</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-10-12T20:13:00Z</dc:date>
    </item>
  </channel>
</rss>

