BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I have just getting started to use SAS Data Integratino Studion 3.4 I have a question to ask.

Problem:
The length of the target column is shorter than the source column. A derived mapping is required between these columns. Do you wan to create an expression?

Eg src data field: student_id; data type numeric; data size 8
target data field: student_id; data type numeric; data size 7

How can I overcome this problem?

Thanks. 😃

Yours Sincerely,
helphelp
17 REPLIES 17
DanielSantos
Barite | Level 11
Actually this is quite wrong.
You are trying to populate a variable that is shorter in size (1 byte less) than the source expression, so truncation may occur.

The right way to avoid this, would be resize BOTH variables to a desired value.
What is the range of values of the student_id var?

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.
deleted_user
Not applicable
Thanks for the reply.

What if there is a situation like this, what should be done when you are mapping the source column to the target column? Is there any function to change the data size?

Thanks.

Yours Sincerely,
helphelp
DanielSantos
Barite | Level 11
Yes there is.

Check the online documentation for the TRUNC function:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000245963.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.
DanielSantos
Barite | Level 11
Have you tried this?

> Yes there is.
>
> Check the online documentation for the TRUNC
> function:
> http://support.sas.com/documentation/cdl/en/lrdict/617
> 24/HTML/default/a000245963.htm
>
> Cheers from Portugal.
>
> Daniel Santos @ www.cgd.pt.
Peter_C
Rhodochrosite | Level 12
nope
looking at it now, it is interesting and useful outside of DI, but...
but in the DI environment, you need to register such column attributes, or you lose them.. Possibly the same will happen in E.G.

PeterC
DanielSantos
Barite | Level 11
Hello Peter.

I was actually asking HelpHelp, because he/she had already posted the question before, and that was my answer.

From my SAS DI Studio experience there is nothing wrong mapping different variable sizes (bigger to smaller, which is the case), IF an expression is specified to convert/truncate the source value. SAS DI Studio uses the same principle, as stated in the error message.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.
LinusH
Tourmaline | Level 20
The easiest way I found in these situations is just to map using a derived expression, and just pick/print the source columns name.
As discussed earlier, you need to be sure that truncation (loss of numeric precision) will not occur, but going from 8 to 7 bytes should in most cases be safe, at least if only integers is to be stored.

/Linus
Data never sleeps
GertNissen
Barite | Level 11
When mapping you can create an expression using i.e. trim(), strip(), substr() or another function to change the length.

But remember to look into why you wan't to change the length on your target table.
DanielSantos
Barite | Level 11
> When mapping you can create an expression using i.e.
> trim(), strip(), substr() or another function to
> change the length.
>
> But remember to look into why you wan't to change the
> length on your target table.

True for alphanumeric variables, which is not the case.

Of course you could always convert them to alpha, trim, then back to numeric. But, a little bit confusing to do.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.
GertNissen
Barite | Level 11
ups, sorry your right - had not seen it was a numeric variable - my fault.
deleted_user
Not applicable
Is there a function to cahnge the data size of the numeric data type without changing the data?

E.g. student id = 12345678 data size 7 (source)

same as

student id = 12345678 data size 8 (target)

Thanks

Yours Sincerely,
helphelp
Peter_C
Rhodochrosite | Level 12
it is not a function that sets a numeric variable's length, but the data definition.
In the mapping where the variable is first defined, see if you can set its properties, including its length.

PeterC
deleted_user
Not applicable
Hi Guys,

Thanks for helping me out.


the trunc function only allows you change from a smaller size ( i.e from a data size 8 to 7)

What if I am needed the other way round ( E.g. from a data size 7 to data size 😎
the trunc function will not allow me to do that.

So, is there any function that allows me to do this kind of upsizing the data size? )

Thanks

Yours Sincerely,
helphelp
LinusH
Tourmaline | Level 20
To "upscale" a column, numeric or char, you don't need any function, both SAS programming wise and in DI Studio, you just map the columns 1:1.
/Linus
Data never sleeps

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 17 replies
  • 1723 views
  • 0 likes
  • 5 in conversation