BookmarkSubscribeRSS Feed
France
Quartz | Level 8

when I import a .csv file in SAS by following code,

53   data SASDATA.PubNew ;
54    %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
55   infile 'R:/Li/P/Pub.csv' DLM = ',' DSD missover lrecl = 32767
55 ! firstobs = 3 ;
56   informat pat_publn_id :29.
57   publn_auth :$29.
58   publn_nr :29.
59   publn_nr_original :29.
60   publn_kind:$29.
61   appln_id :29.
62   publn_date :YYMMDD10.
63   publn_lg :$29.
64   publn_first_grant :29.
65   publn_claims :29.5 ;
66   format pat_publn_id :29.
67   publn_auth :$29.
68   publn_nr :29.
69   publn_nr_original :29.
70   publn_kind:$29.
71   appln_id :29.
72   publn_date :YYMMDDd10.
73   publn_lg :$29.
74   publn_first_grant :29.
75   publn_claims :29.5 ;
76   input
77   pat_publn_id
78   publn_auth $
79   publn_nr
80   publn_nr_original
81   publn_kind $
82   appln_id
83   publn_date
84   publn_lg $
85   publn_first_grant
86   publn_claims ;
87     if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
88   run ;

the result shows

NOTE: Invalid data for publn_date in line 3 24-33.
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
3         777,EP,1943895,,A1,776,2008-07-16,de,0,14 41
pat_publn_id=777 publn_auth=EP publn_nr=1943895 publn_nr_original=. publn_kind=A1 appln_id=776
publn_date=. publn_lg=de publn_first_grant=0 publn_claims=14 _ERROR_=1 _N_=1
NOTE: Invalid data for publn_date in line 4 24-33.
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
4         779,EP,1943896,,A1,778,2008-07-16,de,0,9 40
pat_publn_id=779 publn_auth=EP publn_nr=1943896 publn_nr_original=. publn_kind=A1 appln_id=778
publn_date=. publn_lg=de publn_first_grant=0 publn_claims=9 _ERROR_=1 _N_=2
NOTE: Invalid data for publn_date in line 5 24-33.
5         781,EP,1943898,,A1,780,2008-07-16,de,0,23 41
pat_publn_id=781 publn_auth=EP publn_nr=1943898 publn_nr_original=. publn_kind=A1 appln_id=780
publn_date=. publn_lg=de publn_first_grant=0 publn_claims=23 _ERROR_=1 _N_=3
NOTE: Invalid data for publn_date in line 6 24-33.

 

could you give me some suggestion please? thanks in advance. 

2 REPLIES 2
novinosrin
Tourmaline | Level 20

is there really an informat called 

:YYMMDDd10.

or should it be

:YYMMDD10.

 And i think you do not need a colon format modifier : if you are using informat statement for a modified list input

plus

publn_auth :$29.
58   publn_nr :29.
59   publn_nr_original :29.
60   publn_kind:$29.
61   appln_id :29.

 what are these numeric informats  ? and why?

France
Quartz | Level 8

Thanks novinosrin, I will delete the colon, the Domain of 'publn_date' varibale is DATE and the Default value is 9999-12-31. could you please show me which informat and format should use for it ?

 

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 608 views
  • 2 likes
  • 2 in conversation