DATA Step, Macro, Functions and more

Import of CSV File with Special Characters

Reply
Occasional Contributor
Posts: 15

Import of CSV File with Special Characters

Hi Everyone,

  I am trying to import a CSV file into SAS using an INFILE / INPUT in a data step, however, there is a special character that cuts off the import after 34,121 records (there are over 190,000 records in the source data.  The special character is a right-arrow symbol.  If I manually remove this symbol from the source file before importing, it works fine.  Is there a way to programmatically get around  manually removing these symbols?  I am using SAS v9.1.3 in a Windows environment.  Here is the data step code that I am using:

data QALL                                        ;

     infile '\\kcifile\ORX\ORXNBCVO-NBCVOT\Data\Archive\Import\Query_test.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 TERMSTR=CRLF;

        informat Country $500. ;

        informat Site_ID $389. ;

        informat Site $212. ;

        informat Patient_Identity $157. ;

        informat Patient_Status $133. ;

        informat _DCF_Status $64. ;

        informat Sent_Date $24. ;

       informat Answered_Date $22. ;

        informat Answered_By $31. ;

        informat Closed_Date mmddyy10. ;

        informat Closed_By $33. ;

        informat DCF_Key best32. ;

       informat Query_Name $35. ;

       informat Created_By_Name $31. ;

        informat Created_By_Group $23. ;

        informat Event_Label $39. ;

       informat Event_Date mmddyy10. ;

         informat Form_Label $65. ;

       informat Query_Description $500. ;

         informat Action_Request $1000. ;

        informat Answer $482. ;

         informat Days_Since_Sent best32. ;

        format Country $500. ;

        format Site_ID $389. ;

        format Site $212. ;

        format Patient_Identity $157. ;

        format Patient_Status $133. ;

        format _DCF_Status $64. ;

        format Sent_Date $24. ;

         format Answered_Date $22. ;

        format Answered_By $31. ;

        format Closed_Date mmddyy10. ;

         format Closed_By $33. ;

        format DCF_Key best12. ;

        format Query_Name $35. ;

        format Created_By_Name $31. ;

         format Created_By_Group $23. ;

        format Event_Label $39. ;

        format Event_Date mmddyy10. ;

         format Form_Label $65. ;

        format Query_Description $500. ;

        format Action_Request $1000. ;

         format Answer $482. ;

        format Days_Since_Sent best32. ;

      input

                 Country $

                 Site_ID $

                  Site $

                  Patient_Identity $

                  Patient_Status $

                  _DCF_Status $

                 Sent_Date $

                 Answered_Date $

                 Answered_By $

                  Closed_Date

                 Closed_By $

                  DCF_Key

                  Query_Name $

                  Created_By_Name $

                 Created_By_Group $

                 Event_Label $

                 Event_Date

                  Form_Label $

                  Query_Description $

                  Action_Request $

                  Answer $

                 Days_Since_Sent

     ;

      run;

Thanks in advance!!

-Phil

Super User
Super User
Posts: 6,502

Re: Import of CSV File with Special Characters

Add the IgnoreDOSeof option to the INFILE statement.

45522 - IGNOREDOSEOF option not honored when specified on the FILENAME statement

Occasional Contributor
Posts: 15

Re: Import of CSV File with Special Characters

Hi Tom,

  Thanks so much!!  That worked perfectly!! Smiley Happy

Thanks!

-Phil

Ask a Question
Discussion stats
  • 2 replies
  • 3817 views
  • 3 likes
  • 2 in conversation