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

I have dates stored in a numeric variable of the form YYYYMMDD, with no separator between the day month and year parts. An example is 20090629. I wish to store it in a SAS date field. I am using the following line:

xPolSD = Input(PolSD,yymmddn8.);

but which is giving me an error. I have also tried using

xPolSD = Input(PolSD,yymmdd8.);

which also gives an error.

What is the correct SAS informat to use in this instance?

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Thank you for your feedback.

hope the below code will be more understandable Smiley Happy

data have;

    input date $;

    new_date=input(date,yymmdd8.);

    format new_date date9.;

cards;

20090629

;

run;

Thanks,

Jagadish

Thanks,
Jag

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

You need to put your date first, so it becomes a string.

Data never sleeps
Jagadishkatam
Amethyst | Level 16

As @Linus rightly suggested please convert the numeric value to character and try the below code

data have;

    date="20090629";

    new_date=input(date,yymmdd8.);

    format new_date date9.;

run;

Thanks,

Jagadish

Thanks,
Jag
LinusH
Tourmaline | Level 20

I think you are confusing Mediaeval by treating the date as a constant, not as a columnSmiley Wink

Data never sleeps
Jagadishkatam
Amethyst | Level 16

Thank you for your feedback.

hope the below code will be more understandable Smiley Happy

data have;

    input date $;

    new_date=input(date,yymmdd8.);

    format new_date date9.;

cards;

20090629

;

run;

Thanks,

Jagadish

Thanks,
Jag

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
  • 4 replies
  • 9470 views
  • 6 likes
  • 3 in conversation