BookmarkSubscribeRSS Feed
FP12
Obsidian | Level 7

Hi I have a date like 20180101 which is Numeric 8 and I need to transform it to YYMMDDN8.

 

I am doing it just with a proc sql but it's not working well...

 

like this

SELECT
t1.DN_PEO FORMAT=YYMMDDN8.;

The date is after written like this:

*******************

and still in num 8.

 

Do you know where is the problem here?

4 REPLIES 4
art297
Opal | Level 21

Sounds like you are trying to do something like the following:

data have;
  input DN_PEO;
  cards;
20180101
;

proc sql;
  create table want as
    select input(put(DN_PEO,8.),yymmdd8.) as DN_PEO format=YYMMDDN8.
      from have
  ;
quit;

Art, CEO, AnalystFinder.com

 

 

SuryaKiran
Meteorite | Level 14

Date values in SAS are stored as number of days from 1st Jan 1960. In your example your saying SAS that 20180101 days form 1st Jan 1960. Which is why you are getting *****. First thing is you need to tell SAS how to read data otherwise it will follow its nature.Smiley Wink

 

I suggest use @art297 solution. Converting the numeric values into character and then telling SAS to convert back into numeric date values.

Also you need to understand about FORMAT(How to show data) and INFORMAT (How to read data).

Thanks,
Suryakiran
fabdu92
Obsidian | Level 7

Hi,

 

I have the same problem here!

I used this:

input(put(t1.DAT,8.),YYYYMMDD8.)

And the solution doesn't work for me.

 

I modified the format to YYMMDDN8., so the format is well going from numeric8. to date8. but I also have 

*******************

for every date.

 

 

Do you know why?

 

Some of values of DAT at the top rows of the table are null. Can it explain?

Thanks

art297
Opal | Level 21

You'd have to provide an example of your data. My guess is that your dates are already either date or datetime values and you simply need to add the desired format.

 

I suggest that you create a new thread and ask your question there.

 

Art, CEO, AnalystFinder.com

 

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
  • 4662 views
  • 0 likes
  • 4 in conversation