Hi Experts,
Can anyone tell me why i am getting exponential value for third observation.
data test;
infile datalines dlm=',';
input name $ salary;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,4524542145214
sagar adirala bahu,111111111111
;
run;
Length and Formats are not the same thing.
A format controls how many digits/characters are displayed.
A length controls how many digits/characters are stored in the underlying system.
data test;
infile datalines dlm=',';
length salary 8;
format salary best32.;
input name $ salary;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,9007199254740992
sagar adirala bahu,72057594037927936
;
run;
proc print data=test;
format salary best32.;
run;
Value is too wide 13chars and default format won't display it correctly.
Explicitly specify your format.
data test;
infile datalines dlm=',';
input name $ salary;
format name $50. salary Best32.;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,4524542145214
sagar adirala bahu,111111111111
;
run;
@Rahul_SAS wrote:
Hi Experts,
Can anyone tell me why i am getting exponential value for third observation.
data test;
infile datalines dlm=',';
input name $ salary;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,4524542145214
sagar adirala bahu,111111111111
;
run;
Hi Reeza,
Completely agree with your statement.
However here, I have 2 questions-
1. SAS supports default 8 bytes so only 5 digits should have been read not 12 digits.
2. I have an understanding that while creating a table in a data warehouse we should keep numeric columns so that it will occupy less storage whereas character columns will consume more storage space.
Regarding 1, see this page.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm
8 bytes is numbers as large as 9,007,199,254,740,992
2. Yes they should be numeric, so use 32. if you'd like.
I said character, but I was referring to the number of digits. The default width of the format doesn't display the desired amount of digits is more accurate.
@Rahul_SAS wrote:
Hi Reeza,
Completely agree with your statement.
However here, I have 2 questions-
1. SAS supports default 8 bytes so only 5 digits should have been read not 12 digits.
2. I have an understanding that while creating a table in a data warehouse we should keep numeric columns so that it will occupy less storage whereas character columns will consume more storage space.
@Rahul_SAS wrote:
Hi Reeza,
Completely agree with your statement.
1. SAS supports default 8 bytes so only 5 digits should have been read not 12 digits.
You want to look at what "fits" in 8 bytes. Why would 8 bytes be restricted to 5 digits ever?
From documentation for Windows
Length in Bytes
|
Largest Integer Represented Exactly
|
Exponential Notation
|
Significant Digits Retained
|
---|---|---|---|
3
|
8,192
|
213
|
3
|
4
|
2,097,152
|
221
|
6
|
5
|
536,870,912
|
229
|
8
|
6
|
137,438,953,472
|
237
|
11
|
7
|
35,184,372,088,832
|
245
|
13
|
8
|
9,007,199,254,740,992
|
253
|
15
|
Hi Reeza/Ballardw,
Even using the values given in the table are not working as expected.
data test;
infile datalines dlm=',';
input name $ salary 8.;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,9007199254740992
sagar adirala bahu,72057594037927936
;
run;
Its returning only 8 digits even after applying 8. format.
When Variable Length Equals ... |
Largest Integer z/OS |
Largest Integer Windows or UNIX |
---|---|---|
2 |
256 |
not applicable |
3 |
65,536 |
8,192 |
4 |
16,777,216 |
2,097,152 |
5 |
4,294,967,296 |
536,870,912 |
6 |
1,099,511,627,776 |
137,438,953,472 |
7 |
281,474,946,710,656 |
35,184,372,088,832 |
8 (default) |
72,057,594,037,927,936 |
9,007,199,254,740,992 |
Length in Bytes
|
Largest Integer Represented Exactly
|
Exponential Notation
|
Significant Digits Retained
|
---|---|---|---|
3
|
8,192
|
213
|
3
|
4
|
2,097,152
|
221
|
6
|
5
|
536,870,912
|
229
|
8
|
6
|
137,438,953,472
|
237
|
11
|
7
|
35,184,372,088,832
|
245
|
13
|
8
|
9,007,199,254,740,992
|
253
|
15
|
Length and Formats are not the same thing.
A format controls how many digits/characters are displayed.
A length controls how many digits/characters are stored in the underlying system.
data test;
infile datalines dlm=',';
length salary 8;
format salary best32.;
input name $ salary;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,9007199254740992
sagar adirala bahu,72057594037927936
;
run;
proc print data=test;
format salary best32.;
run;
@Rahul_SAS You are confusing 3 different SAS terms
In your code (below) you are telling SAS to create a variable salary, it will have a default length of 8 bytes, by reading just 8 numeric characters
So your 1st record which has 400000455225 as the second variable, SAS only reads the first 8 characters 400000455
data test;
infile datalines dlm=',';
input name $ salary 8.;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,9007199254740992
sagar adirala bahu,72057594037927936
;
run;
PROC PRINT will default to using BEST12. format to display numeric variables that have no format attached to them.
Use a different format to display the variable.
data test;
infile datalines dsd ;
input name :$30. salary;
format salary comma20.;
datalines;
venkat pati raju,400000455225
vivek rattakonda murali,425
kiran kumar segu,4524542145214
sagar adirala bahu,111111111111
;
proc print;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.