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

Hi Everyone,

 

I have recently created a user-defined format which I have used in formatting a variable on my table. The format works well on temporary tables and reformats the values as needed, but when I try to save the table with formatted values to our Teradata database it strips out the formats and saves values unformatted.

 

I am not sure if anyone knows why this is happening or how to address it.

 

Thanks,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What did you expect SAS to do in that situation?  

When you attach a format to a variable is SAS it just stores the format specification (ie:  'COMMA10.2' ) into the metadata of the dataset. There is no place in Teradata to store that and Teradata wouldn't know what it meant anyway.

 

If you want to use the formats with the table in SAS then just make sure to re-attach the format with a FORMAT statement.

libname mydb teradata .... ;
proc print mydb.mytable;
  format myvar myfmt.;
run;

Otherwise use the format to generate a new character variable withe the decoded value of the variable and store that in Teradata.

data mydb.mytable;
  set mysas.mytable;
  var1_decode = put(var1,fmt.);
run;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Have you tried any of the topis which come up from a Google search?

https://support.sas.com/resources/papers/sgf09/338-2009.pdf

http://support.sas.com/documentation/cdl/en/indbug/68170/HTML/default/viewer.htm#p10m7bigg3hsgbn1f6v...

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

 

Personally I avoid having formats for any data which is not stored only as SAS data - i.e. CSV, databases, transfer files etc. I would always put the full values.  But then I am really not a fan of proprietary binary file formats at all.

Tom
Super User Tom
Super User

What did you expect SAS to do in that situation?  

When you attach a format to a variable is SAS it just stores the format specification (ie:  'COMMA10.2' ) into the metadata of the dataset. There is no place in Teradata to store that and Teradata wouldn't know what it meant anyway.

 

If you want to use the formats with the table in SAS then just make sure to re-attach the format with a FORMAT statement.

libname mydb teradata .... ;
proc print mydb.mytable;
  format myvar myfmt.;
run;

Otherwise use the format to generate a new character variable withe the decoded value of the variable and store that in Teradata.

data mydb.mytable;
  set mysas.mytable;
  var1_decode = put(var1,fmt.);
run;

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!

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