Discussion:
How to change length of a num column
(too old to reply)
Car
2011-01-16 04:59:19 UTC
Permalink
I have a small Q//

how can i change the length of a num column..
i'm unable to change it using alter modify .. since its a num.. can
any1 solve my prob??

ex-
proc sql;
create table dept(deptno num(20), dname char(30), loc varchar(33));
quit;


in the above ex. i have created deptno with length 20..
if i try 2 change it using alter modify.. it doesnt change.. can i
know how to modify the length??
Yuewei Liu
2011-01-16 14:50:33 UTC
Permalink
Post by Car
I have a small Q//
how can i change the length of a num column..
i'm unable to change it using alter modify .. since its a num.. can
any1 solve my prob??
ex-
proc sql;
create table dept(deptno num(20), dname char(30), loc varchar(33));
quit;
in the above ex. i have created deptno with length 20..
if i try 2 change it using alter modify.. it doesnt change.. can i
know how to modify the length??
Just a test..
Reeza
2011-01-16 22:27:53 UTC
Permalink
Post by Car
I have a small Q//
how can i change the length of a num column..
i'm unable to change it using alter modify .. since its a num.. can
any1 solve my prob??
ex-
proc sql;
create table dept(deptno num(20), dname char(30), loc varchar(33));
quit;
in the above ex. i have created deptno with length 20..
if i try 2 change it using alter modify.. it doesnt change.. can i
know how to modify the length??
Does the following work?
data want;
length deptno 2.;
set have;
run;
Lou
2011-01-17 00:58:13 UTC
Permalink
Post by Car
I have a small Q//
how can i change the length of a num column..
i'm unable to change it using alter modify .. since its a num.. can
any1 solve my prob??
ex-
proc sql;
create table dept(deptno num(20), dname char(30), loc varchar(33));
quit;
in the above ex. i have created deptno with length 20..
if i try 2 change it using alter modify.. it doesnt change.. can i
know how to modify the length??
You have NOT created any numeric variable with a length of 20 in SAS. SAS
does not support numeric variables with a length greater than 8.

Numeric variables in SAS have a default length of 8. On a Windows platform,
the largest integer that can be accurately stored is 9,007,199,254,750,992.
The number of significant digits retained is 15.

If you want to change the length of a numeric variable, you can make it
shorter - depending on the platform, numeric variables can be as short as 2
or 3 bytes. On Windows, the lower limit is 3, and the largest integer than
can be stored exactly in 3 bytes is 8,192. The number of significant digits
retained is 3.

Unless disk space is constrained for some reason, it's rarely beneficial to
change the length of a numeric variable - you save a few bytes of space, but
at the cost of accuracy. Unless you know for certain that the value of a
variable will never ever for any reason go above the accuracy limit for a
given length, you're risking undependable results. Changing the length of a
numeric variable affects only the space used to store the variables on disk.
Internally during processing, all numeric variables are expanded to 8 bytes.

What you can do is change the format of a variable - that is, you can change
how a variable is displayed. For instance, you can display a given variable
with format 3. (which will display up to 3 significant digits - if the
number is negative, one position is used to display a minus sign) or 5.
(which will display up to 5 significant digits) and so on up to the limit of
30. (which display up to 30 significant digits). Changing the format
changes the length displayed on the screen or on a printout, but it does not
change the length of the variable - that is, it does not change the amount
of memory used by a program or the amount of space used to store a SAS
dataset on disk.

Loading...