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

Hi, I've to import a database table into a SAS table but I want one of the columns being imported which represents the time period to be converted from a character to a SAs date column.

The orginal period column is in character format as, for example, YYYY-MM-DD  (such as 2013-09-01) but I would like it to be in the format 01SEP2013 as a SAs date column. Here is my code:

  

/* This step imports a file from the DW into a library called current on the C drive */

data current.dos_data;

set mysqlsvr.dos_date_of_supply;

format period default=DATE9.;

informat period default=DATE9.;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21
data have;
  input period $10.;
  cards;
2013-09-01
;

data want (drop=_:);
  set have (rename=(period=_period));
  format period date9.;
  date=input(_period,yymmdd10.);
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

4 REPLIES 4
art297
Opal | Level 21
data have;
  input period $10.;
  cards;
2013-09-01
;

data want (drop=_:);
  set have (rename=(period=_period));
  format period date9.;
  date=input(_period,yymmdd10.);
run;

Art, CEO, AnalystFinder.com

 

ChrisNZ
Tourmaline | Level 20

You can do it on the fly

data CURRENT.DOS_DATA;
  set MYSQLSVR.DOS_DATE_OF_SUPPLY(rename=(PERIOD=PERIODC));
  format PERIOD date9.;
  PERIOD=input(PERIODC,yymmdd10.);
run;
Phil_from_PGA
Calcite | Level 5
Thanks - much appreciated.


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