Hi
Is there any format in SAS that writes the numeric value with a space as thousands separator?
NLNUMIw. writes with a comma (,) 1,000,000
Commax writes with a dot (.) 1.000.000
But I try to find solution for 1 000 000
Any help is appreciated
Try this way:
proc format;
picture mythous00_
low-<0 = '000 000 000 009.00' (prefix="-" multiplier=100)
0 = '0'
0<-high = '000 000 000 009.00' (multiplier=100)
;
picture mythous_
low-<0 = '000 000 000 009' (prefix="-")
0 = '0'
0<-high = '000 000 000 009' ;
run;
data _null_;
do i = -2 to 10;
x = 10**i ;
y = -10**i ;
put @1 i @6 "v1" @10 x mythous00_. @30 y mythous00_. @50 x best32.2;
put @1 i @6 "v2" @10 x mythous_. @30 y mythous_. @50 x best32.2;
end;
run;
Bart
Create your own PICTURE format:
proc format;
picture mythous(dig3sep=' ')
low-high = '000000000009'
;
run;
Untested, posted from my tablet.
Thank you, Kurt. It's with a syntax error.
according to doc. it should be:
proc format;
picture mythous
low-high = '000000000009' (DIG3SEP=' ')
;
run;
but, log seems to be showing something else:
1 proc format; 2 picture mythous 3 low-high = '000000000009' (DIG3SEP=' ') 4 ; NOTE: Format MYTHOUS has been output. 5 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 6 7 8 data _null_; 9 do i = -2 to 10; 10 x = 10**i ; 11 y = -10**i ; 12 put @1 i @10 x mythous. @30 x best32.; 13 end; 14 run; -2 0 0.01 -1 0 0.1 0 1 1 1 10 10 2 100 100 3 1000 1000 4 10000 10000 5 100000 100000 6 1000000 1000000 7 10000000 10000000 8 100000000 100000000 9 1000000000 1000000000 10 10000000000 10000000000 NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.03 seconds
Bart
I did some testing, and I think the dig3sep (and decsep too) wont force a character for separator in a sequence like "000000000009" but rather the instruct SAS which character is used as separator in a sequence. If you compare those tow:
proc format;
picture mythousA
low-high = '000.000.000.009#000' (DIG3SEP='.' decsep="#")
;
picture mythousB
low-high = '000.000.000.009#000' /*(DIG3SEP='.' decsep="#")*/
;
run;
data _null_;
do i = -2 to 10;
x = 10**i ;
y = -10**i ;
put @1 i @10 x mythousA. @30 x mythousB. @50 x best32.;
end;
run;
you will see they are giving different results:
1 proc format; 2 picture mythousA 3 low-high = '000.000.000.009#000' (DIG3SEP='.' decsep="#") 4 ; NOTE: Format MYTHOUSA has been output. 5 picture mythousB 6 low-high = '000.000.000.009#000' /*(DIG3SEP='.' decsep="#")*/ 7 ; NOTE: Format MYTHOUSB has been output. 8 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 9 10 11 data _null_; 12 do i = -2 to 10; 13 x = 10**i ; 14 y = -10**i ; 15 put @1 i @10 x mythousA. @30 x mythousB. @50 x best32.; 16 end; 17 run; -2 0#010 10#000 0.01 -1 0#100 100#000 0.1 0 1#000 1.000#000 1 1 10#000 10.000#000 10 2 100#000 100.000#000 100 3 1.000#000 1.000.000#000 1000 4 10.000#000 10.000.000#000 10000 5 100.000#000 100.000.000#000 100000 6 1.000.000#000 1.000.000.000#000 1000000 7 10.000.000#000 10.000.000.000#000 10000000 8 100.000.000#000 100.000.000.000#000 100000000 9 1.000.000.000#000 0#000 1000000000 10 10.000.000.000#000 1#E16 10000000000 NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the "BEST" format. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.00 seconds
In the first case SAS is able to understand meaning of the dot and hash correctly.
Bart
Try this way:
proc format;
picture mythous00_
low-<0 = '000 000 000 009.00' (prefix="-" multiplier=100)
0 = '0'
0<-high = '000 000 000 009.00' (multiplier=100)
;
picture mythous_
low-<0 = '000 000 000 009' (prefix="-")
0 = '0'
0<-high = '000 000 000 009' ;
run;
data _null_;
do i = -2 to 10;
x = 10**i ;
y = -10**i ;
put @1 i @6 "v1" @10 x mythous00_. @30 y mythous00_. @50 x best32.2;
put @1 i @6 "v2" @10 x mythous_. @30 y mythous_. @50 x best32.2;
end;
run;
Bart
Thank you, yabwon! It works!
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.