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.
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.
;
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.
;
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.
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.
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.