BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
France
Quartz | Level 8

I am trying to import 'earliest_filing_year' and  'earliest_publn_year' from a .csv file into SAS by following codes.

    data SASDATA.TechnicalField ;

    infile 'R:/Li/PATSTAT/TechnicalField.csv' DLM = ',' DSD missover lrecl =32767 firstobs = 3 ;

    input appln_id :29. appln_auth :$29. appln_nr :$29. appln_kind :$29. appln_filing_date :YYMMDD10. appln_filing_year :YEAR10.

appln_nr_epodoc :$50. appln_nr_original :$150. ipr_type :$29. internat_appln_id :29. int_phase :$29. reg_phase :$29. nat_phase :$29.

earliest_filing_date :YYMMDD10. earliest_filing_year :yyyy. earliest_filing_id :29. earliest_publn_date :YYMMDD10. earliest_publn_year :yyyy.

earliest_pat_publn_id :29. granted :29. docdb_family_id :29. inpadoc_family_id :29. docdb_family_size :29. nb_citing_docdb_fam :29.

nb_applicants :29. nb_inventors :29.;

    format appln_filing_date :YYMMDDd10. appln_filing_year :YEAR10. earliest_filing_date :YYMMDDd10. earliest_filing_year :YEAR10.

earliest_publn_date :YYMMDDd10. earliest_publn_year :YEAR10. ;

    run ;

 

I try to use YEAR. and yyyy. to import the attribute but the log shows that

'ERROR 48-59: The informat YEAR was not found or could not be loaded.' and '

ERROR 48-59: The informat YYYY was not found or could not be loaded'

 

the domain of the attribute is a '4 digits in the form yyyy (e.g. 2015)

what should I do for it? thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

A year on its own is just a number, so import it as that (without any informat).

The messages just tell you that such informats do not exist. (there is a format - note the missing "in" - year., but there is no format yyyy. at all).

Try these two statements:

input
  appln_id :29.
  appln_auth :$29.
  appln_nr :$29.
  appln_kind :$29.
  appln_filing_date :YYMMDD10.
  appln_filing_year :YEAR10.
  appln_nr_epodoc :$50.
  appln_nr_original :$150.
  ipr_type :$29.
  internat_appln_id :29.
  int_phase :$29.
  reg_phase :$29.
  nat_phase :$29.
  earliest_filing_date :YYMMDD10.
  earliest_filing_year
  earliest_filing_id :29.
  earliest_publn_date :YYMMDD10.
  earliest_publn_year
  earliest_pat_publn_id :29.
  granted :29.
  docdb_family_id :29.
  inpadoc_family_id :29.
  docdb_family_size :29.
  nb_citing_docdb_fam :29.
  nb_applicants :29.
  nb_inventors :29.
;
format
  appln_filing_date YYMMDDd10.
  appln_filing_year YEAR10.
  earliest_filing_date YYMMDDd10.
  earliest_publn_date :YYMMDDd10.
;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

A year on its own is just a number, so import it as that (without any informat).

The messages just tell you that such informats do not exist. (there is a format - note the missing "in" - year., but there is no format yyyy. at all).

Try these two statements:

input
  appln_id :29.
  appln_auth :$29.
  appln_nr :$29.
  appln_kind :$29.
  appln_filing_date :YYMMDD10.
  appln_filing_year :YEAR10.
  appln_nr_epodoc :$50.
  appln_nr_original :$150.
  ipr_type :$29.
  internat_appln_id :29.
  int_phase :$29.
  reg_phase :$29.
  nat_phase :$29.
  earliest_filing_date :YYMMDD10.
  earliest_filing_year
  earliest_filing_id :29.
  earliest_publn_date :YYMMDD10.
  earliest_publn_year
  earliest_pat_publn_id :29.
  granted :29.
  docdb_family_id :29.
  inpadoc_family_id :29.
  docdb_family_size :29.
  nb_citing_docdb_fam :29.
  nb_applicants :29.
  nb_inventors :29.
;
format
  appln_filing_date YYMMDDd10.
  appln_filing_year YEAR10.
  earliest_filing_date YYMMDDd10.
  earliest_publn_date :YYMMDDd10.
;
ballardw
Super User

Use of the YEAR format with value that only contains a year such as 2018 is going to yield incorrect results.

Please see:

data junk;
   year = 2018;
run;
proc print data=junk;
   var year;
   format year year4.;
run;

Which displays 1965 because a SAS date value is number of days from 1Jan1960 and 2,018 days from then is in 1965.

 

 

With values with only 4 digits you might want to use either F4. or best4. format.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 920 views
  • 0 likes
  • 3 in conversation