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

data dates;

infile datalines;

input State $ Date;

if State='AP' then do;

informat Date ddmmyy10.;

end;

else if State='MP' then do;

informat Date date9.;

end;

datalines;

AP 12/12/2015

AP 13/01/2014

MP 12Dec2015

MP 13Dec2014

;

run;

When I execute the above code snippet, its only accessing the latest loop & showing the o/p.I am unable to see the date formats as desired for both the conditions. May I know where the mistake lies?

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

Use anydtdte informat for both condistions.

data dates;

infile datalines;

input State $ Date :anydtdte.;

format date date9.;

datalines;

AP 12/12/2015

AP 13/01/2014

MP 12Dec2015

MP 13Dec2014

;

run;

View solution in original post

3 REPLIES 3
stat_sas
Ammonite | Level 13

Use anydtdte informat for both condistions.

data dates;

infile datalines;

input State $ Date :anydtdte.;

format date date9.;

datalines;

AP 12/12/2015

AP 13/01/2014

MP 12Dec2015

MP 13Dec2014

;

run;

KachiM
Rhodochrosite | Level 12

INFORMAT is a COMPILE TIME Statement. Hence, originally it was ddmmyy10 but later it is changed to DATE9. . At the EXECUTION TIME, the real INFORMAT is the one that came last namely, DATE9.

Check the CONTENTS of the dates data set:

proc contents data = dates;

run;

and see the inforamat with date9.

KachiM
Rhodochrosite | Level 12

Dear Poster

Look at the note:

If you post a question and someone replies with information that you can use, it's a good idea to mark their reply as either helpful or correct. That way, others who have the same question can quickly see which replies might be most useful for them. A helpful reply is on the right track, while a correct reply answered your question. Keep in mind that you and others get more status points for posting replies that are marked as helpful or correct!

When you click Correct Answer for one of the replies, the original question becomes marked answered and you see a clip of the correct answer in your original question.

To mark responses to your question, go to the question in the community, look for responses, and click Helpful Answer or Correct Answer for each response that fits.  If you want to undo a correct or helpful answer, simply click Unmark as Helpful or Unmark as Correct.

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!

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