Help using Base SAS procedures

Format numeric variable to seperate thousands with a space.

Reply
Regular Contributor
Posts: 186

Format numeric variable to seperate thousands with a space.

Hi,

I have numeric variable that are formated like the following:

format Montant 20.;

What is the proper way to format this variable so that thousands are separated with a space?

PROC Star
Posts: 7,468

Re: Format numeric variable to seperate thousands with a space.

Just curious: where is that used?  There are a couple of formats that separate thousands with either periods or commas.

Regular Contributor
Posts: 186

Re: Format numeric variable to seperate thousands with a space.

It is used by french canadian.

Super User
Posts: 11,343

Re: Format numeric variable to seperate thousands with a space.

Won't claim this is proper but seems to work for me:

 

proc format library=work;

picture mysep

0 - 9999999 = '000 000 000.00' (decsep='.' dig3sep=' ') ;

run;

data _null_;

x= 123456;

put x= mysep.;

run;

PROC Star
Posts: 1,167

Re: Format numeric variable to seperate thousands with a space.

This is handled by the SAS National Language Support routines. Your locale should be "French_Canada".

Give this a try:

options locale=French_Canada;

data _null_;

Montant=123456789;

format Montant nlnum20.2;

put Montant;

run;

Regular Contributor
Posts: 186

Re: Format numeric variable to seperate thousands with a space.

Works Great! Thank you very much.

Quick question, can I put at the very top of my  code and it will be used in each data procedure?

PROC Star
Posts: 7,468

Re: Format numeric variable to seperate thousands with a space.

You could always just put it in either your config or autoexec file.  That way it will be used every time you run SAS.

Ask a Question
Discussion stats
  • 6 replies
  • 3627 views
  • 0 likes
  • 4 in conversation