Help using Base SAS procedures

Proc cport/cimport changes the length from my numeric variable. What to do to solve this?

Reply
Occasional Contributor
Posts: 12

Proc cport/cimport changes the length from my numeric variable. What to do to solve this?

lI have a startdataset in Data Integration Studio 4.21.

Based on this startdataset, I make a derived dataset. For one numeric variables, I change the length.

I have a numeric variable with lentgh 8 from which I want to make a numeric variable with length 5.

I make a job for this. When I ran the job, I get of course a warning that the values will be truncated. (But that is not a problem for me.)

When I check the properties of the derived dataset, I see that the variable has a length of 5, like I have asked.

So far, so good.

Now I need to move the derived dataset from Data Integration Studio 4.21 on a Windowsmachine to SAS Base 9.1 on a Unixmachine.

Therefore, I use proc cport and proc cimport. This works fine except one thing. The length of the numeric variable is not 5 (as defined) but 6.

I did a test. When I define 6 as length in the derived dataset, after the proc cport/cimport, the length is 7.

So the length is always one more after the proc cport/cimport then before. How is this possible? How can I solve this?

I guess it has something to do with the fact that I have changed the length.

For an other numeric variable for which I did not changed the length, I don't see this. length is 8 before and after proc cport/cimport.

screen_DI.bmp

Respected Advisor
Posts: 3,887

Re: Proc cport/cimport changes the length from my numeric variable. What to do to solve this?

I could only guess that the variable length gets increased to maintain numeric precision - but this is a pure guess.

Much more important question: Why are you changing the length of a numeric variable at all? That's not really recommended. You are aware that the length of a numeric variable has not much to do with the "length" of the number you're storing but how many bites are used to store this number. It's very uncommon to change the length of numeric variables and you should have very very good reasons to do so.

Super User
Posts: 10,466

Re: Proc cport/cimport changes the length from my numeric variable. What to do to solve this?

Since the warning message says that the target is too short for specified source that makes me believe that you actually have values that are too large to be stored in 5 bytes, which would be 8 significant digits. Since you have a format associated of 11. that makes me believe that you are likely to have more digits. OR DI is using that format to assign the export length as a length of 6 is allows 11 significant digits.

I would 1) verify that the largest value of the variable has 8 or fewer significant digits and 2) try changing the format before the export to 8. before the export and see if that changes the behavior.

PROC Star
Posts: 7,356

Re: Proc cport/cimport changes the length from my numeric variable. What to do to solve this?

Super User
Posts: 9,662

Re: Proc cport/cimport changes the length from my numeric variable. What to do to solve this?

Or you can use dataset option OUTREP= to generate a UNIX version dataset .Just a workaround.

Ksharp

Ask a Question
Discussion stats
  • 4 replies
  • 279 views
  • 0 likes
  • 5 in conversation