- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If I use the command put(INSD_N,8.1) and values in column INSD_N are like-
80
120
1390
I get output as
80.0
120.0
1390.0
Is there a command which can give me below result
80.00000
120.0000
1390.000
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For the example you have given, format 8.5 works
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
but you get the pesky w.d format too small message.
input y;
put y bestx8.5;
cards;
80
120
1390
;;;;
run;
80.00000
120.0000
1390.000
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data_null_; wrote:
but you get the pesky w.d format too small message.
But if you use BESTX8.5 you get that pesky idea in the back of your head that you shouldn't be using unsupported and undocumented formats ...
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
D format works almost as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want to deal with char, you can also use the repeat function for example:
data want ;
y='33.3';
z=length(y);
v=8-z;
x=catt(y,repeat('0',v-1));
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
none of the solutions are working
i modified the query - but not getting the expected result for data like '2235042'
select CP_N,
case when INSD_N is not missing
then
put(INSD_N,bestx8.5)
else ' '
end as INSD_N
from CCTRP011_CP
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How this is not working for you
data have;
input y;
cards;
80
120
1390
2235042
;
run;
data want;
set have;
yy=strip(put(y,8.1));
z= length(yy);
v=8-z;
x=catt(yy,repeat('0',v-1));
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Guys I am not a SAS expert. So some of the suggestions go bouncer for me.
I would appreciate if someone updates my query so that I can understand the exact solution.
rsubmit;
proc sql;
create table TEST_RESULT as
select CP_N,
case when INSD_N is not missing
then put(INSD_N,8.1)
else ' '
end as INSD_N
from CCTRP011_CP
except
select CP_N, INSD_N
from CSTDM111_CUSTOMER
where CUST_DIM not in (0,1,2);
select count(*) from TEST_RESULT;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This does not appear to have anything to do with this thread. Post it as a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is the same question.
Earlier I had given values. Now I am giving the query.
Because I am not able to apply the solution provided in my query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So when you convert INSD_N from numeric to character it is still not matching the character strings in the other table?
If the numbers require less than the full 8 characters when converted from number to character with the PUT() function then they will be RIGHT aligned with the PUT() function result. Usually character variables are LEFT align. Try wrapping the PUT() function inside of a LEFT() function and see if it helps.
N=5.3
put(N,8.1) -> ' 5.3'