proc format library = fodat.cat_formats ;
picture frmt_num_spac_comma
0 - 9999999 = '000 000 000,00000' (decsep=',' dig3sep=' ') ;
run ;
data encours ;
input montant ;
datalines ;
123456.12345
;
data encours2 ;
set encours ;
montant2 = put(montant,frmt_num_spac_comma.);
run ;
Hello,
I have the amount 123456,12345 and I would like to get 123 456,123456. (space thousand separator)
so I appply a format (by creating an amount2) that I created. the display is correct but the format of the amount2 is character and I would like numeric. How can I fix this ?
thanks a lot in adance.
Nasser
If you want to keep a number and display a formatted value then you apply the format to the number rather than converting to character, something like:
proc format library=fodat.cat_formats; picture frmt_num_spac_comma 0-9999999='000 000 000,00000' (decsep=',' dig3sep=' '); run ; data encours; input montant; format montant frmt_num_spac_comma.; datalines; 123456.12345 ; run;
If you want to keep a number and display a formatted value then you apply the format to the number rather than converting to character, something like:
proc format library=fodat.cat_formats; picture frmt_num_spac_comma 0-9999999='000 000 000,00000' (decsep=',' dig3sep=' '); run ; data encours; input montant; format montant frmt_num_spac_comma.; datalines; 123456.12345 ; run;
thanks a lot RW9.
may I ask an added question.
I try to export the amount into excel via ODS and proc report.
I specified this define montant / '' format = frmt_num_spac_comma. ;
but in excel I get a character column. what should I specify into this line above to get a numeric.
thanks a lot
Think we covered this:
Its an Excel issue, Excel reads the tagset created by SAS and processes it. If you have the format in Excel and it is in Normal.dot - this is the base file Excel uses, then you should be able to apply it.
thanks but I created the format # ##0,00000 in excel and by doing
style(column)={tagattr='format:# ##0,00000'}
I get 225 353,74 (only two deci)
I don't succeed to get in excel a number format like 225 353,73804
That format doesn't seem to work in Excel. Also note you need to save it in your normal.dot file. Anyways, this is outside the scope of a SAS forum. Best check an Office forum for setting up and using custom formats across files.
Try NLNUM. format. format montant nlnum32.5;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.