Hi Everyone,
Can you please help me to achieve output without any decimal, I have many data , so mainly I need output without decimal.
Input :
17.921 |
7.83 |
379.48 |
1.040.855 |
0 |
1.09 |
237.703 |
1.11 |
4.387 |
Output
17921 |
783 |
37948 |
1040855 |
0 |
109 |
237703 |
111 |
4387 |
What type of variable is this? If it is character you can just use the COMPRESS() function to remove the period.
If it is numeric then can you explain why it makes any sense to remove the period? How did the values get recorded with the decimal place in the wrong place to begin with? It would probably be better to fix it there instead of after the fact. If you really need to remove the period then it might be easiest to just convert the number to a string and remove the period and then convert the string back into a number.
data want ;
set have;
string = compress(string,'.');
number = input(compress(put(number,best32.),'.'),32.);
run;
What type of variable is this? If it is character you can just use the COMPRESS() function to remove the period.
If it is numeric then can you explain why it makes any sense to remove the period? How did the values get recorded with the decimal place in the wrong place to begin with? It would probably be better to fix it there instead of after the fact. If you really need to remove the period then it might be easiest to just convert the number to a string and remove the period and then convert the string back into a number.
data want ;
set have;
string = compress(string,'.');
number = input(compress(put(number,best32.),'.'),32.);
run;
Given your number 1.040.855 with two dots this looks to me more like the display of a integer that uses dot as thousand separator and comma for decimal like it's common in many European countries.
Because this is likely just about display (print) of numbers a simple change of the format used for display will give you what you want.
Below to demonstrate what I'm talking about.
%let sv_locale=%sysfunc(getoption(locale,keyword));
options locale=German_Germany;
data have;
input numvar_1;
numvar_2=numvar_1;
numvar_3=numvar_1;
format numvar_1 nlnum16. numvar_2 nlnum16. numvar_3 best32.;
datalines;
17921
783
37948
1040855
0
109
237703
111
4387
;
title 'Print (display) numbers using formats from Have';
proc print data=have;
run;
title 'Print (display) numvar_2 using format best32.';
proc print data=have;
format numvar_2 best32.;
run;
title 'Print (display) all numerical variable with format best32.';
proc print data=have;
format _numeric_ best32.;
run;
options &sv_locale;
If above doesn't work for you then please share the result of a Proc Contents of your source data so we can understand what data type and format gets used for your values.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.