BookmarkSubscribeRSS Feed
dkanand86
Calcite | Level 5

Hi,

Can you tell which sas format to use for reading following dates:

1. 12-JAN-14

2. 12-JAN-2014

Thanks

10 REPLIES 10
stat_sas
Ammonite | Level 13

data have;

input (date1 date2) (:anydtdte.);

format date1 date2 date9.;

datalines;

12-JAN-14 12-JAN-2014

;

dkanand86
Calcite | Level 5

I want to view date1 as 12-JAN14 and not as 12-JAN-2014.

Can you suggest a format which can do this?

data_null__
Jade | Level 19

Why not DATE.?

dkanand86
Calcite | Level 5

No, date. does not work, as it gives same output. Pls help.

Untitled.png

art297
Opal | Level 21

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

;

dkanand86
Calcite | Level 5

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

;

dkanand86
Calcite | Level 5

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;

art297
Opal | Level 21

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

;

dkanand86
Calcite | Level 5

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;

bharathtuppad
Obsidian | Level 7

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-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!

What is Bayesian Analysis?

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.

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
  • 10 replies
  • 1081 views
  • 0 likes
  • 5 in conversation