<?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: Using ARRAY and Scan function delimiter &amp;quot;|&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563706#M158058</link>
    <description>&lt;P&gt;You cannot use the same name to mean two different things.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also make sure to define the new variables type (and length).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array _name $30 Lab_Name1-Lab_Name79;
  array _date 8 Lab_Date1-Lab_Date79;
  format Lab_Date1-Lab_Date79 yymmdd10.;
  array _value $30 Lab_Value1-Lab_Value79;
  do I= 1 do dim(_name);
    _name[i]=scan(Lab_Name,I,"|");
    _date[i]=input(scan(LabDate,i,'|'),mmddyy10.);
    _value[i]= scan(LabValue,i,'|');
  end;
  drop i LabName labDate labValue ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 Jun 2019 14:04:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-05T14:04:04Z</dc:date>
    <item>
      <title>Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563692#M158053</link>
      <description>&lt;P&gt;I received a raw data from other hospital and they combine individual their&amp;nbsp; all lab dates, lab names, lab values, and lab units into one column and using "|" as delimiter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying combine array and scan to separate them into columns but it's not working for me,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is my coding,&lt;/P&gt;
&lt;P&gt;ARRAY LabName(*) Lab_Name1-Lab_Name79;&lt;BR /&gt;DO I= 1 TO dim(LabName);&lt;BR /&gt;LabName(I)=scan(Lab_Name,I,"|");&lt;BR /&gt;END;&lt;BR /&gt;DROP I;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is the raw data looks like&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 240pt;" border="0" width="320" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Lab Date&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Lab Name&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Lab Value&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Lab Unit&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008&lt;/TD&gt;
&lt;TD&gt;Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC&lt;/TD&gt;
&lt;TD&gt;39.1|13.1|25.3|33.5|75.3|8.1|200|5.19|18.0|9.6|9.6&lt;/TD&gt;
&lt;TD&gt;%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011|10/12/2011&lt;/TD&gt;
&lt;TD&gt;Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC&lt;/TD&gt;
&lt;TD&gt;36.2|12.4|25.8|34.3|75.0|8.9|208|4.83|18.4|5.1|5.1&lt;/TD&gt;
&lt;TD&gt;%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;3&lt;/TD&gt;
&lt;TD&gt;10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011|10/05/2011&lt;/TD&gt;
&lt;TD&gt;Cell Morphology|Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC&lt;/TD&gt;
&lt;TD&gt;Yes|40.0|13.7|25.4|34.1|74.6|8.7|214|5.37|19.0|5.6|5.6&lt;/TD&gt;
&lt;TD&gt;|%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;4&lt;/TD&gt;
&lt;TD&gt;09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012|09/28/2012&lt;/TD&gt;
&lt;TD&gt;Cell Morphology|Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC&lt;/TD&gt;
&lt;TD&gt;Yes|40.2|13.2|24.6|32.8|74.8|9.2|194|5.38|18.7|8.7|8.7&lt;/TD&gt;
&lt;TD&gt;|%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;5&lt;/TD&gt;
&lt;TD&gt;11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012|11/19/2012&lt;/TD&gt;
&lt;TD&gt;Cell Morphology|Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Differential Type|Instr WBC|LD&lt;/TD&gt;
&lt;TD&gt;Yes|39.1|12.8|23.4|32.7|71.5|8.3|243|5.47|21.1|4.8|Yes|4.8|190&lt;/TD&gt;
&lt;TD&gt;|%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|||unit/L&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;6&lt;/TD&gt;
&lt;TD&gt;04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013|04/15/2013&lt;/TD&gt;
&lt;TD&gt;Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC&lt;/TD&gt;
&lt;TD&gt;38.0|12.5|24.1|33.0|73.0|8.6|173|5.21|19.6|4.9|4.9&lt;/TD&gt;
&lt;TD&gt;%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;7&lt;/TD&gt;
&lt;TD&gt;08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013|08/05/2013&lt;/TD&gt;
&lt;TD&gt;Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC&lt;/TD&gt;
&lt;TD&gt;37.9|12.6|24.4|33.1|73.7|9.3|179|5.15|19.4|3.9|3.9&lt;/TD&gt;
&lt;TD&gt;%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;8&lt;/TD&gt;
&lt;TD&gt;09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013|09/30/2013&lt;/TD&gt;
&lt;TD&gt;Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC|LD&lt;/TD&gt;
&lt;TD&gt;38.6|12.8|24.6|33.2|74.1|8.6|207|5.21|19.0|4.2|4.2|223&lt;/TD&gt;
&lt;TD&gt;%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL||unit/L&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;9&lt;/TD&gt;
&lt;TD&gt;01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014|01/21/2014&lt;/TD&gt;
&lt;TD&gt;Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC|Nucleated Red Blood Cells&lt;/TD&gt;
&lt;TD&gt;37.9|12.8|24.0|33.9|70.9|8.5|181|5.34|18.7|5.0|5.0|0.2&lt;/TD&gt;
&lt;TD&gt;%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL||/100 WBC&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;10&lt;/TD&gt;
&lt;TD&gt;06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014|06/02/2014&lt;/TD&gt;
&lt;TD&gt;Albumin|Alkaline Phosphatase|ALT|Anion Gap|AST|Calcium|Carbon Dioxide|Chloride|Glucose Serum|Potassium|Sodium|Total Bilirubin|Urea Nitrogen|CREATININE|Protein Total|Cell Morphology|Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Differential Type|Instr WBC|Nucleated Red Blood Cells|Absolute Retic|Percent Retic|Retic RBC&lt;/TD&gt;
&lt;TD&gt;3.8|83|23|6|16|8.8|27|104|117|3.9|137|0.5|12|0.80|7.9|Yes|38.6|13.0|23.8|33.7|70.7|8.2|201|5.47|19.4|4.1|Yes|4.1|0.1|109.4|2.0|5.47&lt;/TD&gt;
&lt;TD&gt;g/dL|unit/L|unit/L||unit/L|mg/dL|mmol/L|mmol/L|mg/dL|mmol/L|mmol/L|mg/dL|mg/dL|mg/dL|g/dL||%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|||/100 WBC|thou/mcL|%|x10(6)/mcL&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 05 Jun 2019 13:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563692#M158053</guid>
      <dc:creator>Addison</dc:creator>
      <dc:date>2019-06-05T13:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563699#M158055</link>
      <description>&lt;P&gt;Do you need to split LabDate and LabValue, too?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If yes, then creating one observation for each value in the lists is recommended. This leads to cleaner data-structure, which is often easier to use, than a datasets with 100+ variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have(
      rename=(
         LabDate = DateList
         LabName = NameList
         LabValue = ValueList
      )
   );

   length LabDate 8 LabName $ 50 LabValue 8;
   format LabDate mmddyyd10.;

   do i = 1 to countw(NameList, '|');
      LabDate = input(scan(DateList, i, '|'), mmddyy10.);
      LabName = scan(NameList, i, '|');
      LabValue = input(scan(ValueList, i, '|'), best32.);
      output;
   end;

   keep Id Lab:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 13:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563699#M158055</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-06-05T13:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563706#M158058</link>
      <description>&lt;P&gt;You cannot use the same name to mean two different things.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also make sure to define the new variables type (and length).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array _name $30 Lab_Name1-Lab_Name79;
  array _date 8 Lab_Date1-Lab_Date79;
  format Lab_Date1-Lab_Date79 yymmdd10.;
  array _value $30 Lab_Value1-Lab_Value79;
  do I= 1 do dim(_name);
    _name[i]=scan(Lab_Name,I,"|");
    _date[i]=input(scan(LabDate,i,'|'),mmddyy10.);
    _value[i]= scan(LabValue,i,'|');
  end;
  drop i LabName labDate labValue ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jun 2019 14:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563706#M158058</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-05T14:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563738#M158067</link>
      <description>Is the data originally in a text file or in a SAS data set? If the original file is a text file and this is the full structure you need to change how you import the data, not fix it after the fact. &lt;BR /&gt;&lt;BR /&gt;If it is a SAS data set, I'm assuming this is one variable among others that are already read in correctly?</description>
      <pubDate>Wed, 05 Jun 2019 15:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563738#M158067</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T15:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563739#M158068</link>
      <description>&lt;P&gt;The original raw data is .csv file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use proc import to bring data to SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 15:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563739#M158068</guid>
      <dc:creator>Addison</dc:creator>
      <dc:date>2019-06-05T15:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563744#M158070</link>
      <description>It's not CSV if the delimiter is a pipe which is why it wasn't read in correctly. Unless this is only one field among many others that were read in correctly.You need to use PROC IMPORT with the delimiter option or write your own code.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc import out=want datafile='path to file' dbms=dlm replace;&lt;BR /&gt;delimiter='|';&lt;BR /&gt;guessingrows=max;*will be a bit slower;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 05 Jun 2019 16:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563744#M158070</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T16:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563754#M158076</link>
      <description>&lt;P&gt;Our affiliate IT team save those data files as csv format and using "|" as delimiter upload to our data warehouse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I directly import those .csv files to SAS, SAS will not read them correctly.&lt;/P&gt;
&lt;P&gt;SAS will read those data files correctly only if I convert them to .xlsx format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 16:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563754#M158076</guid>
      <dc:creator>Addison</dc:creator>
      <dc:date>2019-06-05T16:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563756#M158078</link>
      <description>Because they are not CSV. CSV means comma separated values, but your file doesn't have comma's, it has pipes as the delimiter. &lt;BR /&gt;&lt;BR /&gt;Did you try the code I suggested? Or when importing via GUI, select as a text file and specify the delimiter. Excel is already converting the delimiter for you which is why SAS reads that correctly. But your file is not CSV and treating it as such is what's causing this issue.</description>
      <pubDate>Wed, 05 Jun 2019 16:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563756#M158078</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T16:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563759#M158079</link>
      <description>&lt;P&gt;Actually the way the text posted in the original message looks it appears to be a TAB delimited file with three long character fields that have individual values delimited by pipe character.&amp;nbsp; But that might have been caused by copying a pasting from an Excel file instead copying lines from the original file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the long fields always have&amp;nbsp; the same number of pipe characters (instead of only including enough for the number of actual values) then you might be able to read the original file using two characters as the delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want help reading the original file then post the first few lines of the actual file (not the file as converted by being opened by Excel).&amp;nbsp; Open the file in a text editor (the SAS program editor should work) and copy a few lines. Then use the Insert Code icon in for forum editor to get a pop-up text box where you can paste the lines.&amp;nbsp; That way the forum editor won't try to convert the lines into paragraphs.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 16:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563759#M158079</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-05T16:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563838#M158097</link>
      <description>&lt;P&gt;I use notepad to copy couple raw data and attached here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help!!&lt;/P&gt;
&lt;P&gt;I am looking forward a good solution to import these raw data files. I will receive them monthly and I am tired of keeping covert them to excel file and import them.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 19:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563838#M158097</guid>
      <dc:creator>Addison</dc:creator>
      <dc:date>2019-06-05T19:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563841#M158098</link>
      <description>I try the code you suggest, looks like SAS don't think it's .CSV file so did not read record correctly.&lt;BR /&gt;proc import out=want datafile='Z:\lab_06032019.csv' &lt;BR /&gt;dbms=dlm replace;&lt;BR /&gt;delimiter='|';&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jun 2019 19:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563841#M158098</guid>
      <dc:creator>Addison</dc:creator>
      <dc:date>2019-06-05T19:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563861#M158106</link>
      <description>I don't know what htat means. Can you please explain? Did the code not work? What does the log say?</description>
      <pubDate>Wed, 05 Jun 2019 19:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563861#M158106</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T19:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563862#M158107</link>
      <description>Ok, first read it in as a tab delimited file.And then you'll need to parse it out in SAS. &lt;BR /&gt;&lt;BR /&gt;proc import out=want datafile='path to file' dbms=tab replace;run;&lt;BR /&gt;&lt;BR /&gt;Do you want the measures to be in their own columns (wide file) or output to their own rows for a long file?</description>
      <pubDate>Wed, 05 Jun 2019 19:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563862#M158107</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T19:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563925#M158132</link>
      <description>&lt;P&gt;That's a weird file you have here.&lt;/P&gt;
&lt;P&gt;You can read the whole original file in one go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "%sysfunc(pathname(WORK))\t.txt" lrecl=500;
  put '12312231';
  put '68879';
  put '09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/19/2008|09/18/2008' 
      '09'x
      'Hematocrit|Hemoglobin|MCH Blood|MCHC Blood|MCV Blood|MPV|Platelet Count|RBC|RDW|WBC|Instr WBC'
      '09'x
      '39.1|13.1|25.3|33.5|75.3|8.1|200|5.19|18.0|9.6|9.6'
      '09'x
      '%|g/dL|pg|g/dL|fL|fL|thou/mcL|x10(6)/mcL|%|thou/mcL|';
run;

data WANT;
  infile "%sysfunc(pathname(WORK))\t.txt" lrecl=500 pad dlm='|' _infile_=BUFF;
  input @ ;
  _infile_ =translate(BUFF,'|','09'x);    
  if char(BUFF,3)='/' then  
    input @1 (DATE1-DATE11) (:mmddyy10.) (M1-M11) (:$25.) (R1-R11) (:best.) (V1-V11) (:$20.);    
  else input @1 NUM best.; 
  format DATE1-DATE11 date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not too sure the structure is useful though:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;NUM&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DATE1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DATE2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;M1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;M2&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;R1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;R2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;V1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;V2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;12312231&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;68879&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;19SEP2008&lt;/TD&gt;
&lt;TD class="r data"&gt;19SEP2008&lt;/TD&gt;
&lt;TD class="l data"&gt;Hematocrit&lt;/TD&gt;
&lt;TD class="l data"&gt;Hemoglobin&lt;/TD&gt;
&lt;TD class="r data"&gt;39.1&lt;/TD&gt;
&lt;TD class="r data"&gt;13.1&lt;/TD&gt;
&lt;TD class="l data"&gt;%&lt;/TD&gt;
&lt;TD class="l data"&gt;g/dL&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 23:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563925#M158132</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-06-05T23:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using ARRAY and Scan function delimiter "|"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563936#M158140</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42661"&gt;@Addison&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The attached sample data really helps to understand what you're dealing with.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below sample code reads your source data into a long format which is often an easier structure to deal with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let source_file=c:\temp\test file.txt;
data long(drop=_:);
  attrib 
    id          length=$15    informat=$15.
    fin         length=$15    informat=$15. 
    _lab_dates  length=$400   informat=$400.
    _lab_names  length=$400   informat=$400.
    _lab_values length=$400   informat=$400.
    _lab_units  length=$400   informat=$400.
    lab_date    length=8      informat=mmddyy10. format=date9.
    lab_name    length=$40
/*    lab_value   length=8*/
    lab_value   length=$40
    lab_unit    length=$40
    ;

  infile "&amp;amp;source_file" dlm='09'x dsd truncover firstobs=2 lrecl=1650;
  input id fin _lab_dates _lab_names _lab_values _lab_units;

  /* start: if rows without lab data not required then remove below code */ 
  if cmiss(_lab_dates, _lab_names, _lab_values, _lab_units)=4 then output;
  else
  /* end: of remove section */
  do;
    _loop_cnt=1+max(countc(_lab_dates,'|'), countc(_lab_names,'|'), countc(_lab_values,'|'), countc(_lab_units,'|'));
    do _i=1 to _loop_cnt;
      lab_date=input(scan(_lab_dates,_i,'|','M'),mmddyy10.);
      lab_name=scan(_lab_names,_i,'|','M');
/*      lab_value=input(scan(_lab_values,_i,'|'),best32.);*/
      lab_value=scan(_lab_values,_i,'|','M');
      lab_unit=scan(_lab_units,_i,'|','M');
      output;
    end;
  end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;I wasn't sure if you also need the rows without Lab data. If not then remove the section as per comment in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 575px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30029i83C557385282C265/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Changes - new code version&lt;/P&gt;
&lt;P&gt;1. change type of lab_value to character because there are "yes" strings in the source data (is this a DQ issue?)&lt;/P&gt;
&lt;P&gt;2. add 'M' modifier to scan() function to read data correctly in case of missing data elements&lt;/P&gt;
&lt;P&gt;3. add '1' to loop counter to read all the pipe delimited data elements&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 21:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ARRAY-and-Scan-function-delimiter-quot-quot/m-p/563936#M158140</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-06-06T21:24:43Z</dc:date>
    </item>
  </channel>
</rss>

