<?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: Unconcatenate column while keeping dataset sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557780#M155545</link>
    <description>&lt;P&gt;Try add blank into split char and use 'M' option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set have;
  patient=scan(patient_id, 1, '| ','m');
  variable=scan(patient_id, 2, '| ','m');
  date=scan(patient_id, 3, '| ','m');
  visit=scan(patient_id, 4, '| ','m');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 May 2019 14:25:46 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-05-10T14:25:46Z</dc:date>
    <item>
      <title>Unconcatenate column while keeping dataset sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557612#M155463</link>
      <description>&lt;P&gt;I have a a dataset where the first row is concatenated, delimited by '|'. I am using the following code to unconcatenate it.&amp;nbsp;This works fine but then I want to drop patient_id which ends up deleting some patient rows. I suspect this has to do with the 'uniqueness' of the row but I am not sure. How can I unconcatenate, drop patient_id and keep all the rows?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set have;
  patient=scan(patient_id, 1, '|');
  variable=scan(patient_id, 2, '|');
  date=scan(patient_id, 3, '|');
  visit=scan(patient_id, 4, '|');
run;
have:
patiend_id                   Ht Wt Bm
DH-4-1|H|28SEP2017:00:00:00  55 55 55
DH-4-1|W|22SEP2017:00:00:00|A 55 55 55
DH-4-1|H|22SEP2017:00:00:00|B 55 55 55
want:
patiend_id variable         Date       Visit    Ht Wt Bm
DH-4-1       H      28SEP2017:00:00:00          55 55 55
DH-4-1       W      22SEP2017:00:00:00   A      55 55 55
DH-4-1       H      22SEP2017:00:00:00   B      55 55 55
what&amp;nbsp;I'm&amp;nbsp;getting if I drop patient_id: 
patiend_id variable         Date       Visit    Ht Wt Bm
DH-4-1       W      22SEP2017:00:00:00   A      55 55 55&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 21:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557612#M155463</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-05-09T21:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Unconcatenate column while keeping dataset sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557630#M155470</link>
      <description>Is this from a text file? How did you originally read it into SAS?</description>
      <pubDate>Thu, 09 May 2019 22:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557630#M155470</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-09T22:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unconcatenate column while keeping dataset sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557631#M155471</link>
      <description>&lt;P&gt;So how are you "dropping patient_id"? You don't show any code. Your result:&lt;/P&gt;
&lt;PRE&gt;what I'm getting if I drop patient_id: 
patiend_id variable         Date       Visit    Ht Wt Bm
DH-4-1       W      22SEP2017:00:00:00   A      55 55 55&lt;/PRE&gt;
&lt;P&gt;looks like you have done something to remove PATIENT, not patien_id&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you may be using Delete, which removes records, not variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are attempting to conditionally remove patient_id, then than isn't quite possible. A variable is either in or not in a data set. The statement would be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
  set have;
  patient=scan(patient_id, 1, '|');
  variable=scan(patient_id, 2, '|');
  date=scan(patient_id, 3, '|');
  visit=scan(patient_id, 4, '|');

  drop patient_id;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which means that the output data set would never have the variable patient_id but keeps patient, variable, date, visit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you would be better not to call the value "date" as it has a time component and SAS makes a big difference between date and datetime values.&lt;/P&gt;
&lt;P&gt;Also, read and treat as a datetime:&lt;/P&gt;
&lt;P&gt;Instead of&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;patient_id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&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;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;try &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;datetime = input(scan(patient_id,3,'|'),datetime.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;format datetime datetime.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;OR if all of your times are 00:00:00 because of some other sources slopping program and you actually want a DATE then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;datetime = input(scan(patient_id,3,'|'),date9.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;format datetime date9.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;There are many tools in SAS to work with actual date, time or datetime values and likely anything you want to with that value will require creating a date or datetime value first, might as well do it first thing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 22:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557631#M155471</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-09T22:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unconcatenate column while keeping dataset sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557780#M155545</link>
      <description>&lt;P&gt;Try add blank into split char and use 'M' option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set have;
  patient=scan(patient_id, 1, '| ','m');
  variable=scan(patient_id, 2, '| ','m');
  date=scan(patient_id, 3, '| ','m');
  visit=scan(patient_id, 4, '| ','m');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 May 2019 14:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unconcatenate-column-while-keeping-dataset-sas/m-p/557780#M155545</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-10T14:25:46Z</dc:date>
    </item>
  </channel>
</rss>

