🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-29-2019 10:05 AM
(3252 views)
data Abun_dw20d_summary ; informat bins $30.; format bins $30.; length bins $30.;
input bins $ CM1DW20D CM3DW20D CW1DW20D ODWD W1DW4D;
datalines;
Acinetobacter 2477.123456789 195 163 45 77
Actinoalloteichus 2431 220 198 69.123456789 6774
Bacillus 2456 173 155 78 785
Bletilla 2412 135 116.123456789 45 123;
run;
proc transpose data=Abun_dw20d_summary out=bint;
var _all_;
by bins;
run;
My decimals are getting truncated in output dataset, can anyone help me on this?
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
Providing a format seems to take care of the issue for me:
Hope this helps,
cynthia
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@mahi2pal wrote:data Abun_dw20d_summary ; informat bins $30.; format bins $30.; length bins $30.; input bins $ CM1DW20D CM3DW20D CW1DW20D ODWD W1DW4D; datalines; Acinetobacter 2477.123456789 195 163 45 77 Actinoalloteichus 2431 220 198 69.123456789 6774 Bacillus 2456 173 155 78 785 Bletilla 2412 135 116.123456789 45 123; run; proc transpose data=Abun_dw20d_summary out=bint; var _all_; by bins; run;
My decimals are getting truncated in output dataset, can anyone help me on this?
Did you notice this?
NOTE: Numeric variables in the input data set will be converted to character in the output data set.
SAS used a default format I think BEST12.
If you want more decimal places use a different format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
Providing a format seems to take care of the issue for me:
Hope this helps,
cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Where do give the format?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It is highlighted in yellow in the screen shot in my previous posting.
Cynthia
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
1) Don't include the character variables in the VAR statement and PROC TRANSPOSE will not convert your numeric variables to character.
2) If you must include the character variables then attach a format to the numeric variables that is long enough.
Example:
data have ;
length bins $30.;
input bins CM1DW20D CM3DW20D ;
datalines;
Acinetobacter 2477.123456789 195
Bletilla 2412 116.123456789
;
proc print width=min; title 'HAVE';
format _numeric_ best32.;
run;
proc transpose data=have out=want1;
by bins;
run;
proc print width=min; title 'WANT1';
format _numeric_ best32.;
run;
proc transpse data=have out=want2;
by bins;
var _all_;
format _numeric_ best32.;
run;
proc print width=min; title 'WANT2';
run;
title;
HAVE Obs bins CM1DW20D CM3DW20D 1 Acinetobacter 2477.123456789 195 2 Bletilla 2412 116.123456789 WANT1 Obs bins _NAME_ COL1 1 Acinetobacter CM1DW20D 2477.123456789 2 Acinetobacter CM3DW20D 195 3 Bletilla CM1DW20D 2412 4 Bletilla CM3DW20D 116.123456789 WANT2 Obs bins _NAME_ COL1 1 Acinetobacter bins Acinetobacter 2 Acinetobacter CM1DW20D 2477.123456789 3 Acinetobacter CM3DW20D 195 4 Bletilla bins Bletilla 5 Bletilla CM1DW20D 2412 6 Bletilla CM3DW20D 116.123456789