BookmarkSubscribeRSS Feed
aola
Fluorite | Level 6

I execute the proc sql pass through (Teradata to SAS).

 

%let sql=select current_date from sys_calendar.calendar 

 

proc sql noprint;

CONNECT TO TERADATA(Authdomain= SERVER= mode=);

CREATE table &number AS SELECT * FROM CONNECTION TO TERADATA (&sql.);

DISCONNECT FROM TERADATA; QUIT;

 

I have a problem because I am seeing date format as DATEw. but I need format 'YYYY-MM-DD'.

I know I can do that:

select a, period_date format=yymmdd10. as c, b FROM CONNECTION TO TERADATA

 

I have a date format: 13MAY2016, but I need: '2016-05-12' but I have about 150 sqls, so I prefer a more global solution than a new format for each sql. Can I use some options? I need the same for each date, so I wolud like do that in global way.

3 REPLIES 3
Kalind_Patel
Lapis Lazuli | Level 10

Hello @aola;

 

You can use SASDATEFMT option like that in your query;

( sasdatefmt=( date1='datetime21.') ) 

 

This is the link for more info:

http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a001371624.htm

Ksharp
Super User

You can always change these format after importing into SAS.

Assuming all the table stored at WORK library.

 

%let lib=work;

data _null_;
 set sashelp.vcolumn(where=(libname="%upcase(&lib)" and format='DATE9.')) end=last;
 by memname;
 if _n_=1 then call execute(catt("proc datasets library=&lib nolist nodetails;"));
 if first.memname then call execute(catx(" ","modify ",memname,"; format"));
 call execute(catx(" ",name," yymmdd10."));
 if last.memname then call execute(";");
 if last then call execute("quit;");
run;
aola
Fluorite | Level 6

Thank you, you're amazing 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3503 views
  • 1 like
  • 3 in conversation