Hi,
Can you tell which sas format to use for reading following dates:
1. 12-JAN-14
2. 12-JAN-2014
Thanks
data have;
input (date1 date2) (:anydtdte.);
format date1 date2 date9.;
datalines;
12-JAN-14 12-JAN-2014
;
I want to view date1 as 12-JAN14 and not as 12-JAN-2014.
Can you suggest a format which can do this?
Why not DATE.?
No, date. does not work, as it gives same output. Pls help.
proc format;
picture datex (default = 😎
low-high = '%d-%b%y'
(datatype = date);
run;
data have;
input (date1 date2) (:anydtdte.);
format date1 datex.;
format date2 date9.;
datalines;
12-JAN-14 12-JAN-2014
;
Just tweaked a bit!
its works now. Thanks!
proc format;
picture datex (default = 10)
low-high = '%d-%b-%y'
(datatype = date);
run;
data have2;
input (date1 date2) (:anydtdte.);
format date1 datex.;
format date2 date9.;
datalines;
12-JAN-14 12-JAN-2014
;
The following code is giving a date format issue:
I have created format (named datex) for loan_issue_date variable. But, when i run following code, the code gives error stating "DATEX format not found". Please help.!
Code:
proc format library=deep fmtlib cntlout=deep.fmts;
picture datex (default = 10)
low-high = '%d-%b-%y'
(datatype = date);
run;
options fmtsearch=(deep work);
data deep.customer_loan_detail;
infile cards;
input
cust_id 4.
acct_number $8.
customer_loan_type : $8.
loan_issue_date anydtdte.
loan_amount 5.
loan_flag $3.;
format loan_issue_date date9.;
datalines;
1034 C734459 CAR 05-APR-12 22789 YES
2498 C657568 HOME 05-MAR-12 100387 YES
6523 C673121 HOME 04-SEP-05 87982 YES
8677 C367420 HOME 19-SEP-13 35876 YES
5487 C784509 CAR 02-AUG-11 14990 YES
8496 C741298 PERSONAL 12-JUL-10 5500 YES
;
run;
You're confusing formats with informats. I think you are trying to accomplish something like the following:
proc format library=deep fmtlib cntlout=deep.fmts;
picture datex (default = 9)
low-high = '%d-%b-%y'
(datatype = date);
run;
options fmtsearch=(deep work);
data deep.customer_loan_detail;
infile cards;
input
cust_id
acct_number $8.
customer_loan_type : $8.
loan_issue_date anydtdte9.
loan_amount
loan_flag $3.;
format loan_issue_date datex.;
datalines;
1034 C734459 CAR 05-APR-12 22789 YES
2498 C657568 HOME 05-MAR-12 100387 YES
6523 C673121 HOME 04-SEP-05 87982 YES
8677 C367420 HOME 19-SEP-13 35876 YES
5487 C784509 CAR 02-AUG-11 14990 YES
8496 C741298 PERSONAL 12-JUL-10 5500 YES
;
The following code is giving a date format issue:
I have created format (named datex) for loan_issue_date variable. But, when i run following code, the code gives error stating "DATEX format not found". Please help.!
Code:
proc format library=deep fmtlib cntlout=deep.fmts;
picture datex (default = 10)
low-high = '%d-%b-%y'
(datatype = date);
run;
options fmtsearch=(deep work);
data deep.customer_loan_detail;
infile cards;
input
cust_id 4.
acct_number $8.
customer_loan_type : $8.
loan_issue_date datex.
loan_amount 5.
loan_flag $3.;
format loan_issue_date date9.;
datalines;
1034 C734459 CAR 05-APR-12 22789 YES
2498 C657568 HOME 05-MAR-12 100387 YES
6523 C673121 HOME 04-SEP-05 87982 YES
8677 C367420 HOME 19-SEP-13 35876 YES
5487 C784509 CAR 02-AUG-11 14990 YES
8496 C741298 PERSONAL 12-JUL-10 5500 YES
;
run;
As mentioned by Arthur, you are creating a format and using it as informat in the input statement and that's why you are getting the error.
The error message that you get in your code is about informat.
ERROR 48-59: The informat DATEX was not found or could not be loaded.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.