<?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: Datalines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500667#M133365</link>
    <description>&lt;P&gt;Some kind of magic touch I guess? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Joking aside, when I run your exact code I get a messed up result as well. You have a blank line as the first line inside the datalines. Usually in SAS, a blank line does not matter. However, inside the datalines is a whole other story and care must be taken.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Oct 2018 10:48:43 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-10-02T10:48:43Z</dc:date>
    <item>
      <title>Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500350#M133237</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a file with the codes below but there is something wrong because my first row of data is messed up. How can I fix this. Also, if I want to add to add datetime variable to this data, how can I do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; work.transfuse;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;infile&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; datalines &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;delimiter&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New"&gt;","&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; Type $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; Result $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;500&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; Encounter Type $ Result $;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1240,Blood Transfusion Reason,Anemia&lt;/P&gt;&lt;P&gt;1240,Packed RBC Transfusion Template,Blood Transfusion Results 08/24/2018 04:21 Hemoglobin 6.9 gm/dL 08/24/2018 01:29 BG-Lactate 1.33 mmol/L 08/24/2018 07:00 Systolic BP 101 mmHg 08/24/2018 07:00 Heart Rate 95 bpm&lt;/P&gt;&lt;P&gt;1240,Transfusion Indications Hemoglobin,Hemoglobin [Hgb] &amp;lt; 8gm/dL&lt;/P&gt;&lt;P&gt;1250,Blood Transfusion Reason,Anemia&lt;/P&gt;&lt;P&gt;1250,Packed RBC Transfusion Template,Blood Transfusion Results 08/22/2018 12:00 Systolic BP 120 mmHg 08/22/2018 12:00 Heart Rate 67 bpm&lt;/P&gt;&lt;P&gt;1250,Transfusion Indications Hemoglobin,Hemoglobin [Hgb] &amp;lt; 8gm/dL&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;print&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=work.transfuse;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500350#M133237</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-10-01T13:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500353#M133238</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want the datetime variable to contain?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.transfuse;
infile datalines delimiter=",";
length Type $100 Result $500;
input Encounter Type $ Result $;
dt=datetime();
format dt datetime20.;
datalines;
1240,Blood Transfusion Reason,Anemia
1240,Packed RBC Transfusion Template,Blood Transfusion Results 08/24/2018 04:21 Hemoglobin 6.9 gm/dL 08/24/2018 01:29 BG-Lactate 1.33 mmol/L 08/24/2018 07:00 Systolic BP 101 mmHg 08/24/2018 07:00 Heart Rate 95 bpm
1240,Transfusion Indications Hemoglobin,Hemoglobin [Hgb] &amp;lt; 8gm/dL
1250,Blood Transfusion Reason,Anemia
1250,Packed RBC Transfusion Template,Blood Transfusion Results 08/22/2018 12:00 Systolic BP 120 mmHg 08/22/2018 12:00 Heart Rate 67 bpm
1250,Transfusion Indications Hemoglobin,Hemoglobin [Hgb] &amp;lt; 8gm/dL
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500353#M133238</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-01T13:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500355#M133240</link>
      <description>&lt;P&gt;The reason you have bad output is because your data contains the delimiter.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1240,Blood Transfusion Reason,Anemia&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; ^&lt;/P&gt;
&lt;P&gt;Here are two delimiters, you are reading two variables, so the third word carries over.&lt;/P&gt;
&lt;P&gt;In a standard conformant csv file, text strings which contain the delimiter must be surrounded by quotes, e.g:&lt;/P&gt;
&lt;P&gt;1240,"Blood Transfusion Reason,Anemia"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise it is not a csv file, and you will need to read the whole line in one input, then post process out the various parts later with substr or scan.&amp;nbsp; Get the file into a proper CSV file format and avoid all this trouble.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500355#M133240</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-01T13:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500359#M133243</link>
      <description>&lt;P&gt;I want date and time&amp;nbsp;in this format 08/24/2018 08:23:00. It would be different for each encounter.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500359#M133243</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-10-01T13:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500368#M133250</link>
      <description>&lt;P&gt;How did you fix this? I cannot see any difference in your codes and my codes but your output is not messed up.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500368#M133250</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-10-01T13:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500663#M133362</link>
      <description>&lt;P&gt;I figured it out, there was nothing wrong with my codes. Just because of space between datalines was causing that error.&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 10:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500663#M133362</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2018-10-02T10:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500667#M133365</link>
      <description>&lt;P&gt;Some kind of magic touch I guess? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Joking aside, when I run your exact code I get a messed up result as well. You have a blank line as the first line inside the datalines. Usually in SAS, a blank line does not matter. However, inside the datalines is a whole other story and care must be taken.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 10:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines/m-p/500667#M133365</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-02T10:48:43Z</dc:date>
    </item>
  </channel>
</rss>

