BookmarkSubscribeRSS Feed
turcay
Lapis Lazuli | Level 10

Hello everyone,

 

I have a sample code as below, I try to see datetime27.6 format being a character format. I mean, I want to convert the format of variable but not convert view of variable.

 

Here is my sample code and desired output. Can somebody help me, please?

 

/*Sample data*/
Data Have;
Length Numeric 8;
Infile Datalines Missover;
Input Numeric ;
Format Numeric DATETIME27.6;
Datalines;
201001
201002
201003
201004
201005
201006
201007
201008
201009
201010
201011
201012
;
Run;

 

Numeric.png

Thank you,

2 REPLIES 2
BenbowL
Fluorite | Level 6

Hi turcay,

 

The put function should do this for you

 

Data Have;
Length Numeric 8;
Infile Datalines Missover;
Input Numeric ;
Format Numeric DATETIME27.6;
Datalines;
201001
201002
201003
201004
201005
201006
201007
201008
201009
201010
201011
201012
;
Run;

data want;
set have;
char = put(numeric,DATETIME27.6);
run;
ballardw
Super User

What value does this actually represent?  201001

From your displayed values, my first guess is that this is a 4-digit year and then a 2-digit month. What would you expect the displayed value to be?

 

 

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!

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
  • 2 replies
  • 1259 views
  • 1 like
  • 3 in conversation