<?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: Reading Pipe delimited file with CVS extension in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884693#M349520</link>
    <description>&lt;P&gt;Why does the file have all of those commas at the end of the line?&lt;BR /&gt;Did you accidentally open the original CSV file in EXCEL and then re-save it?&amp;nbsp; If so can you get back to the original file before it was touched by EXCEL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even so the file works fine for me.&amp;nbsp; You just might have to add a step to clean up that last field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv "C:\downloads\pipedelimted with CSV extension.csv";

proc import file=csv dbms=csv out=test replace;
  delimiter='|';
run;

proc print width=min;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;                                                        Principal_
Obs    TRIALID      COUNTRYID    Country    SITEID     Investigator              Location_Name             SUBJID    SUBJID2

 1    GCT1046-04       ES         Spain     ES004     Fern, Miguel       Clinica Universidad de Navarra     1001      1001
 2    GCT1046-04       ES         Spain     ES004     Fero, Miguel       Clinica Universidad de Navarra     1002      1002
 3    GCT1046-04       ES         Spain     ES007     Ram, Inmaculada    Hospital Virgen de la Victoria     1004      1004

                                                        Active_                                               Dose_
Obs   YOB     Current_Status            On_Treatment    Inactive        Part         Cohort                  Regimen

 1    1969    Enrolled                       Y          Active      Safety Run-In    Safety Run-in: Arm C      Q6W
 2    1961    Screen Failure                 N          Inactive    Safety Run-In    n/a                       n/a
 3    1964    Treatment Discontinued         N          Inactive    Safety Run-In    Safety Run-in: Arm C      Q6W


Obs   Stratum    Treatment_Name                  Visit_Name                    Visit_Date     Treatment_Dose

 1      n/a      Treatment Arm C  fexo 400mg     Enrollment (Cycle 1 Day 1)    01-DEC-2021    100 mg,400 mg,400 mg,400 mg,400 mg
 2      n/a      n/a                             Screen Failure                03-DEC-2021    n/a
 3      n/a      Treatment Arm C - pEXO 400mg    Screening                     11-JAN-2022    n/a


Obs   Kit_Numbers_Assigned             Kit_Type_Description

 1    10203,30063,30064,30065,30066    xxxx02 100 mg/vial,Pex 100mg/vial,fexo 100mg/vial,teri 100mg/vial,Fetto 100mg/vial
 2    n/a                              n/a
 3    n/a                              n/a


Obs   Lot_Numbers_Assigned

 1    E222115-0004L001,E222115-0003L001,E222115-0003L001,E222115-0003L001,E222115-0003L001
 2    n/a
 3    n/a

                                                                                              Kit_Verification_
Obs   Batch_Numbers_Assigned                                                                        Date

 1    E222115-0004L001,E222115-0003L001,E222115-0003L001,E222115-0003L001,E222115-0003L001           n/a
 2    n/a                                                                                            n/a
 3    n/a                                                                                            n/a


Obs   Username______________________

 1    De la Guardia, Eduardo
 2    De la Guardia, Eduardo,,,,,,,,,,,,,,,,,,,,
 3    Fern YUI, Desireeh,,,,,,,,,,,,,,,,,,,,&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;Step to remove the trailing commas from USERNAME (and rename it also).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fixed;
  set test ;
  length username $80 ;
  username=translate(trim(translate(trim(Username______________________),', ',' ,')),', ',' ,');
run;

proc print;
 var username: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    Username______________________                       username

 1     De la Guardia, Eduardo                        De la Guardia, Eduardo
 2     De la Guardia, Eduardo,,,,,,,,,,,,,,,,,,,,    De la Guardia, Eduardo
 3     Fern YUI, Desireeh,,,,,,,,,,,,,,,,,,,,        Fern YUI, Desireeh
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2023 18:02:50 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-07-13T18:02:50Z</dc:date>
    <item>
      <title>Reading Pipe delimited file with CVS extension</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884691#M349519</link>
      <description>&lt;P&gt;Hi, I am trying to read this (attached) pipe delimited file into SAS but&amp;nbsp; proc import throw's an error like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4936 proc import&lt;BR /&gt;4936! datafile="C:\Users\test\VisitSummary.csv"&lt;BR /&gt;4937 out=IRT&lt;BR /&gt;4938 dbms=csv replace ;&lt;BR /&gt;4939&lt;BR /&gt;4940 DELIMITER='|';&lt;BR /&gt;4941 getnames=Yes;&lt;BR /&gt;4942 datarow=2;&lt;BR /&gt;4943 run;&lt;/P&gt;
&lt;P&gt;Unable to sample external file, no data in first 5 records.&lt;BR /&gt;ERROR: Import unsuccessful. See SAS Log for details.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 3.54 seconds&lt;BR /&gt;cpu time 0.12 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data step has no error but it always comes as 0 observation.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;4944 data WORK.IRT_2 ;&lt;BR /&gt;4945 infile 'C:\Users\test\VisitSummary.csv'&lt;BR /&gt;4946 delimiter = '|' DSD&amp;nbsp; lrecl=32767 firstobs=2 missover;&lt;BR /&gt;4947&lt;BR /&gt;4948 input&lt;BR /&gt;4949&lt;BR /&gt;4950 TRIALID $&lt;BR /&gt;4951 COUNTRYID $&lt;BR /&gt;4952 Country $&lt;BR /&gt;4953 SITEID $&lt;BR /&gt;4954 Principal_Investigator $&lt;BR /&gt;4955 Location_Name $&lt;BR /&gt;4956 SUBJID $&lt;BR /&gt;4957 SUBJID2 $&lt;BR /&gt;4958 YOB $&lt;BR /&gt;4959 Current_Status On_Treatment $&lt;BR /&gt;4960 Active_Inactive $&lt;BR /&gt;4961 Part $&lt;BR /&gt;4962 Cohort $&lt;BR /&gt;4963 Dose_Regimen $&lt;BR /&gt;4964 Stratum $&lt;BR /&gt;4965 Treatment_Name $&lt;BR /&gt;4966 Visit_Name $&lt;BR /&gt;4967 Visit_Date $&lt;BR /&gt;4968 Treatment_Dose $&lt;BR /&gt;4969 Kit_Numbers_Assigned $&lt;BR /&gt;4970 Kit_Type_Description $&lt;BR /&gt;4971 Lot_Numbers_Assigned $&lt;BR /&gt;4972 Batch_Numbers_Assigned $&lt;BR /&gt;4973 Kit_Verification_Date $&lt;BR /&gt;4974 Username $&lt;BR /&gt;4975 ;&lt;BR /&gt;4976 run;&lt;/P&gt;
&lt;P&gt;NOTE: The infile 'C:\Users\test\VisitSummary.csv' is:&lt;BR /&gt;Filename=C:\Users\test\VisitSummary.csv,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=147679,&lt;BR /&gt;Last Modified=13Jul2023:10:01:54,&lt;BR /&gt;Create Time=29Nov2021:12:42:10&lt;/P&gt;
&lt;P&gt;NOTE: 0 records were read from the infile&lt;BR /&gt;'C:\Users\test\VisitSummary.csv'.&lt;BR /&gt;NOTE: The data set WORK.IRT_2 has 0 observations and 26 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 3.32 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me read this file into SAS. I am not sure what mistake I am doing here. I have attached a copy of the file as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 17:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884691#M349519</guid>
      <dc:creator>k26_23</dc:creator>
      <dc:date>2023-07-13T17:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Pipe delimited file with CVS extension</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884693#M349520</link>
      <description>&lt;P&gt;Why does the file have all of those commas at the end of the line?&lt;BR /&gt;Did you accidentally open the original CSV file in EXCEL and then re-save it?&amp;nbsp; If so can you get back to the original file before it was touched by EXCEL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even so the file works fine for me.&amp;nbsp; You just might have to add a step to clean up that last field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv "C:\downloads\pipedelimted with CSV extension.csv";

proc import file=csv dbms=csv out=test replace;
  delimiter='|';
run;

proc print width=min;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;                                                        Principal_
Obs    TRIALID      COUNTRYID    Country    SITEID     Investigator              Location_Name             SUBJID    SUBJID2

 1    GCT1046-04       ES         Spain     ES004     Fern, Miguel       Clinica Universidad de Navarra     1001      1001
 2    GCT1046-04       ES         Spain     ES004     Fero, Miguel       Clinica Universidad de Navarra     1002      1002
 3    GCT1046-04       ES         Spain     ES007     Ram, Inmaculada    Hospital Virgen de la Victoria     1004      1004

                                                        Active_                                               Dose_
Obs   YOB     Current_Status            On_Treatment    Inactive        Part         Cohort                  Regimen

 1    1969    Enrolled                       Y          Active      Safety Run-In    Safety Run-in: Arm C      Q6W
 2    1961    Screen Failure                 N          Inactive    Safety Run-In    n/a                       n/a
 3    1964    Treatment Discontinued         N          Inactive    Safety Run-In    Safety Run-in: Arm C      Q6W


Obs   Stratum    Treatment_Name                  Visit_Name                    Visit_Date     Treatment_Dose

 1      n/a      Treatment Arm C  fexo 400mg     Enrollment (Cycle 1 Day 1)    01-DEC-2021    100 mg,400 mg,400 mg,400 mg,400 mg
 2      n/a      n/a                             Screen Failure                03-DEC-2021    n/a
 3      n/a      Treatment Arm C - pEXO 400mg    Screening                     11-JAN-2022    n/a


Obs   Kit_Numbers_Assigned             Kit_Type_Description

 1    10203,30063,30064,30065,30066    xxxx02 100 mg/vial,Pex 100mg/vial,fexo 100mg/vial,teri 100mg/vial,Fetto 100mg/vial
 2    n/a                              n/a
 3    n/a                              n/a


Obs   Lot_Numbers_Assigned

 1    E222115-0004L001,E222115-0003L001,E222115-0003L001,E222115-0003L001,E222115-0003L001
 2    n/a
 3    n/a

                                                                                              Kit_Verification_
Obs   Batch_Numbers_Assigned                                                                        Date

 1    E222115-0004L001,E222115-0003L001,E222115-0003L001,E222115-0003L001,E222115-0003L001           n/a
 2    n/a                                                                                            n/a
 3    n/a                                                                                            n/a


Obs   Username______________________

 1    De la Guardia, Eduardo
 2    De la Guardia, Eduardo,,,,,,,,,,,,,,,,,,,,
 3    Fern YUI, Desireeh,,,,,,,,,,,,,,,,,,,,&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;Step to remove the trailing commas from USERNAME (and rename it also).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fixed;
  set test ;
  length username $80 ;
  username=translate(trim(translate(trim(Username______________________),', ',' ,')),', ',' ,');
run;

proc print;
 var username: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    Username______________________                       username

 1     De la Guardia, Eduardo                        De la Guardia, Eduardo
 2     De la Guardia, Eduardo,,,,,,,,,,,,,,,,,,,,    De la Guardia, Eduardo
 3     Fern YUI, Desireeh,,,,,,,,,,,,,,,,,,,,        Fern YUI, Desireeh
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 18:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884693#M349520</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-13T18:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Pipe delimited file with CVS extension</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884695#M349521</link>
      <description>&lt;P&gt;Normally that is a symptom of a file created by EXCEL on a MAC.&amp;nbsp; It seems that Excel never got the memo that MacOS is now a flavor of UNIX and it generates text files with CR as the end of line string instead of the LF that is normally used on UNIX.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename irt "C:\Users\test\VisitSummary.csv" termstr=cr;
proc import dbms=csv datafile=irt out=irt replace;
  delimiter='|';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2023 18:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884695#M349521</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-13T18:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Pipe delimited file with CVS extension</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884697#M349523</link>
      <description>&lt;P&gt;Yes, I did re-save it since I Dint want to post the entire files here.&amp;nbsp; Also when I opened the files both in excel and notepad I did not find any comma anywhere in the files.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 18:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884697#M349523</guid>
      <dc:creator>k26_23</dc:creator>
      <dc:date>2023-07-13T18:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Pipe delimited file with CVS extension</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884698#M349524</link>
      <description>&lt;P&gt;This one work perfectly . Thank you very much.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 18:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Pipe-delimited-file-with-CVS-extension/m-p/884698#M349524</guid>
      <dc:creator>k26_23</dc:creator>
      <dc:date>2023-07-13T18:29:36Z</dc:date>
    </item>
  </channel>
</rss>

