@EliajhBazarski wrote:
Hi, thanks. I used format informat _all_. Only Result Viewer displays this, but viewtable not. Maybe, problem with SAS settings?
Nothing is wrong.
I assume by "Result Viewer" you mean the output of some procedure. Which procedure? Is it PROC PRINT?
If you don't give PROC PRINT a specific format to use it will try its best to make a nice output.
Experiment.
data test;
input x @@;
cards;
1 2 3 4 1.1 1.2 1.1234
;
proc print data=test;
run;
proc print data=test;
where x=int(x);
run;
proc print data=test;
format x 4.1;
run;
Obs x 1 1.0000 2 2.0000 3 3.0000 4 4.0000 5 1.1000 6 1.2000 7 1.1234 Obs x 1 1 2 2 3 3 4 4 Obs x 1 1.0 2 2.0 3 3.0 4 4.0 5 1.1 6 1.2 7 1.1
@EliajhBazarski wrote:
I set dataset with var A only integer: 1 3 4
And set dataset with var A 1.1 2.1 2.2;
After setting together my integer values 1 3 4 turns to 1.0 3.0 4.0. Are any logical errors there, options to fix it in SAS Base?
Numbers are numbers. There is no difference between 1 and 1.0 or for that matter 00001 and 1.00000. It is all the number one.
Most likely the reason is that the other dataset is using a different FORMAT to display the values. When you combine two or more dataset that have the same variable the first format the data step compiler sees is the one that is used. So if the first dataset in the SET statement did no have any special format attached to the variable and the second one did then that is the format that will be attached to the variable in the new dataset.
Or it is just that it is displaying the values for the variable with a consistent number of decimal places across all observations. And now that some of the values are non-integers it is displaying the decimal places for all of the values.
INFORMAT is irrelevant here, as informats control how data is read, not how it is displayed.
@EliajhBazarski wrote:
Hi, thanks. I used format informat _all_. Only Result Viewer displays this, but viewtable not. Maybe, problem with SAS settings?
Nothing is wrong.
I assume by "Result Viewer" you mean the output of some procedure. Which procedure? Is it PROC PRINT?
If you don't give PROC PRINT a specific format to use it will try its best to make a nice output.
Experiment.
data test;
input x @@;
cards;
1 2 3 4 1.1 1.2 1.1234
;
proc print data=test;
run;
proc print data=test;
where x=int(x);
run;
proc print data=test;
format x 4.1;
run;
Obs x 1 1.0000 2 2.0000 3 3.0000 4 4.0000 5 1.1000 6 1.2000 7 1.1234 Obs x 1 1 2 2 3 3 4 4 Obs x 1 1.0 2 2.0 3 3.0 4 4.0 5 1.1 6 1.2 7 1.1
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.