BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I'm trying to read the CSV file via File Reader Transformation in SAS DI Studio 4.2. My CSV file has 10 variables and 3 observations. After executing the File Reader Transformation, I see that blank values are displayed for all the 3 observations and variables. Appreciate if someone of you guide me to resolve the issue.

 

My CSV file looks as follows:

 

Transaction ID,"Policy Number","Plate Number","Client Name","Policy Start Date","Inserted By","Status","Inserted Date","Start Date","End Date"
1,"900203422","1DKB299","Diur. EEN SANItHTY-TEST",2018-02-21,"BOKT","Policy processed successfully",2018-02-16 08:49:32,2018-02-16 08:49:32,2018-02-16 08:50:30

 

Table which I see after running File Reader Transformation:

 

Blank values.PNG

 

Code which was being generated in the File Reader Transformation:

 


data work.etls_W6X4DRR5 / view = work.etls_W6X4DRR5 ; 
   infile "/data/trans/Transaction_*.csv"
          lrecl = 1200
          delimiter = ','
          dsd
          missover
          firstobs = 2; 
   ; 
   attrib TRANSACTION_ID length = 8
      format = 11.
      informat = 11.; 
   attrib POLICY_NUMBER length = $20
      format = $20.
      informat = $20.; 
   attrib PLATE_NUMBER length = $20
      format = $20.
      informat = $20.; 
   attrib CLIENT_NAME length = $50
      format = $50.
      informat = $50.; 
   attrib POLICY_START_DATE length = $20
      format = $20.
      informat = $20.; 
   attrib INSERTED_BY length = $20
      format = $20.
      informat = $20.; 
   attrib STATUS length = $50
      format = $50.
      informat = $50.; 
   attrib INSERTED_DATE length = 8
      format = DATETIME25.6
      informat = anydtdtm24.; 
   attrib START_DATE length = 8
      format = DATETIME25.6
      informat = anydtdtm24.; 
   attrib END_DATE length = 8
      format = DATETIME25.6
      informat = anydtdtm24.; 
   
   input TRANSACTION_ID POLICY_NUMBER PLATE_NUMBER CLIENT_NAME POLICY_START_DATE 
         INSERTED_BY STATUS INSERTED_DATE START_DATE END_DATE; 
   
run; 

Screenshot of my Job window:

 

FR1.PNG

 

 

1 REPLY 1
Patrick
Opal | Level 21

@Babloo

It works for me by just using the code and data you've posted. Ideally post your sample data as attachment and as unchanged as possible.

 

One theory why things are not working for you: You're in a Windows environment but your source file comes from a Unix/Linux environment and the end-of-line character is only LF and not CRLF.

You're using DIS4.2 which means you're still on SAS 9.2  ....and that's a bad thing as since SAS 9.3 the INFILE statement has a TERMSTR= option for such cases which makes everything very simple.

 

If it's the LF / CRLF challenge then I'm honestly no more sure how that needs to be approached using SAS9.2. May be the PRINT/NOPRINT option could help?

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm

 

Else you'll have to read the data as byte stream and parse it on your own (which means user written code).

 

And here the code which I've run successfully:

filename mydata temp;
data _null_;
  file mydata;
  put 'Transaction ID,"Policy Number","Plate Number","Client Name","Policy Start Date","Inserted By","Status","Inserted Date","Start Date","End Date"';
  put '1,"900203422","1DKB299","Diur. EEN SANItHTY-TEST",2018-02-21,"BOKT","Policy processed successfully",2018-02-16 08:49:32,2018-02-16 08:49:32,2018-02-16 08:50:30';
  stop;
run;

data work.etls_W6X4DRR5 / view = work.etls_W6X4DRR5 ; 
   infile mydata
          lrecl = 1200
          delimiter = ','
          dsd
          missover
          firstobs = 2; 
   ; 
   attrib TRANSACTION_ID length = 8
      format = 11.
      informat = 11.; 
   attrib POLICY_NUMBER length = $20
      format = $20.
      informat = $20.; 
   attrib PLATE_NUMBER length = $20
      format = $20.
      informat = $20.; 
   attrib CLIENT_NAME length = $50
      format = $50.
      informat = $50.; 
   attrib POLICY_START_DATE length = $20
      format = $20.
      informat = $20.; 
   attrib INSERTED_BY length = $20
      format = $20.
      informat = $20.; 
   attrib STATUS length = $50
      format = $50.
      informat = $50.; 
   attrib INSERTED_DATE length = 8
      format = DATETIME25.6
      informat = anydtdtm24.; 
   attrib START_DATE length = 8
      format = DATETIME25.6
      informat = anydtdtm24.; 
   attrib END_DATE length = 8
      format = DATETIME25.6
      informat = anydtdtm24.; 
   
   input TRANSACTION_ID POLICY_NUMBER PLATE_NUMBER CLIENT_NAME POLICY_START_DATE 
         INSERTED_BY STATUS INSERTED_DATE START_DATE END_DATE; 
   
run; 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1231 views
  • 0 likes
  • 2 in conversation