Hi All,
we have coulm called size and that is defined by byites but we need to convert that varaible into GBs/TBs. and total size of all files.
can you advice on this.
proc report data=test nofs;
title1 "Simple Report";
column FILE SIZE ;
define FILE / display;
define SIZE / analysis sum;
rbreak after / summarize;
compute SIZE;
size=size/1024;
endcomp;
run;
Use an adaptive format:
data test;
input file $ size;
datalines;
A 2000
B 20000
C 200000
D 2000000
E 20000000
F 200000000
G 2000000000
H 20000000000
I 200000000000
J 2000000000000
K 20000000000000
;
proc format;
picture sizes
0-10240 = "00009"
10240-10485760 = "00009K" (mult=0.0009765625)
10485761 - 10737418240 = "00009M" (mult=9.5367431640625E-7)
10737418241 - 10995116277760 = "00009G" (mult=9.3132257461548E-10)
10995116277761 - high = "0000009T" (mult=9.0949470177292E-13)
;
run;
proc report data=test nofs;
title1 "Simple Report";
column FILE SIZE ;
define FILE / display;
define SIZE / analysis sum format=sizes.;
rbreak after / summarize;
run;
You can tweak the cutoff values, and the picture to include digits after the decimal point.
Please tell us what is not working properly with the code you show.
Hi
sorry I was not crear.
size column is in bytes so we want to convert that into GBs/Tbs
ex:sample data in bytes.
need an output like below as bytes will be caliclated like size=(((size)/1024)/1024) to get in GBs
file
|
size(in GBs) |
aa | 0.000977 |
bb | 0.00193 |
cc | 0.001812 |
ff | 1.3125 |
hh | 20.8125 |
total |
22.12972
data test;
infile cards;
input file $ size;
cards;
aa 1024
bb 2024
cc 1900
ff 1376256
hh 21823488
;
run;
proc report data=test nofs;
title1 "Simple Report";
column FILE SIZE ;
define FILE / display;
define SIZE / analysis sum;
rbreak after / summarize;
compute SIZE;
size=size/1024;
endcomp;
run;
@sathya66 wrote:
Hi
sorry I was not crear.
size column is in bytes so we want to convert that into GBs/Tbs
ex:sample data in bytes.
need an output like below as bytes will be caliclated like size=(((size)/1024)/1024) to get in GBs
filesize(in GBs) aa 0.000977 bb 0.00193 cc 0.001812 ff 1.3125 hh 20.8125 total 22.12972
It's still not clear to me. You haven't told me what is wrong with the program or the output you get from the program, other than the very obvious you want a different formula for SIZE in the compute block, and you state above the correct formula.
I played around with the format to make it look a little better:
proc format;
picture sizes
0-10240 = "00,009"
10240-10485760 = "00,009.00K" (mult=0.09765625)
10485761 - 10737418240 = "00,009.00M" (mult=9.5367431640625E-5)
10737418241 - 10995116277760 = "00,009.00G" (mult=9.3132257461548E-8)
10995116277761 - high = "0,000,009.00T" (mult=9.0949470177292E-11)
;
run;
Use an adaptive format:
data test;
input file $ size;
datalines;
A 2000
B 20000
C 200000
D 2000000
E 20000000
F 200000000
G 2000000000
H 20000000000
I 200000000000
J 2000000000000
K 20000000000000
;
proc format;
picture sizes
0-10240 = "00009"
10240-10485760 = "00009K" (mult=0.0009765625)
10485761 - 10737418240 = "00009M" (mult=9.5367431640625E-7)
10737418241 - 10995116277760 = "00009G" (mult=9.3132257461548E-10)
10995116277761 - high = "0000009T" (mult=9.0949470177292E-13)
;
run;
proc report data=test nofs;
title1 "Simple Report";
column FILE SIZE ;
define FILE / display;
define SIZE / analysis sum format=sizes.;
rbreak after / summarize;
run;
You can tweak the cutoff values, and the picture to include digits after the decimal point.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.