Or just use the appropriate LOCALE setting then you can use the NLMNY format.
92 %let locale=%sysfunc(getoption(locale)); 93 %put &=locale; LOCALE=EN_US 94 options locale='fi_FI'; 95 data test; 96 Montant_min_de_vers_init=1500; 97 test=left(put(Montant_min_de_vers_init,euro10.)); 98 test1=substr(cats(test,char(test,1)),2); 99 test2=translate(test1,' ',','); 100 test3=put(1500,nlmny10.); 101 put (test:) (=:$quote. /); 102 run; test="€1,500" test1="1,500€" test2="1 500€" test3=" 1 500 €" NOTE: The data set WORK.TEST has 1 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 103 options locale="&locale";
Why do a COMPRESS if you don't want the result of COMPRESS?
As far as I know, there is no built in money format that uses a space instead of a comma or a period. Why not use a function that replaces the comma with a space? The TRANSLATE function will do that for you.
Thank you, but unfortunately it doesn't work :
data test;
set ACCORD;
test=compress(put(Montant_min_de_vers_init,euro10.));
test1=compress(substr(test,2))||"€";
test2=translate(test1,',',' ');
keep test test1 test2;
run;
You have typed the arguments to the TRANSLATE function incorrectly. If you want to replace a comma with a space, you would use this
test2=translate(test1,' ',',');
Not sure why you have the COMPRESS() function at all. You have the arguments to TRANSLATE() backwards.
43 data test; 44 Montant_min_de_vers_init=1500; 45 test=put(Montant_min_de_vers_init,euro10.-L); 46 test1=cats(substr(test,2),char(test,1)); 47 test2=translate(test1,' ',','); 48 put (test:) (=:$quote. /); 49 run; test="€1,500" test1="1,500€" test2="1 500€"
Or just use the appropriate LOCALE setting then you can use the NLMNY format.
92 %let locale=%sysfunc(getoption(locale)); 93 %put &=locale; LOCALE=EN_US 94 options locale='fi_FI'; 95 data test; 96 Montant_min_de_vers_init=1500; 97 test=left(put(Montant_min_de_vers_init,euro10.)); 98 test1=substr(cats(test,char(test,1)),2); 99 test2=translate(test1,' ',','); 100 test3=put(1500,nlmny10.); 101 put (test:) (=:$quote. /); 102 run; test="€1,500" test1="1,500€" test2="1 500€" test3=" 1 500 €" NOTE: The data set WORK.TEST has 1 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 103 options locale="&locale";
proc format;
picture fmt
low-high='000 000 000€';
run;
data have;
input x;
want=put(x,fmt. -l);
cards;
1500
12345678
;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.