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 🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4280 views
  • 1 like
  • 3 in conversation