08-07-2014 01:38 AM
I have a query buddies, so need your suggestions.
here goes the problem,
I have a character variables ' x ' and has an observations:
now the above observation i need in the following way:
So how well i do this?
since it is a character type i used scan function and seperated two part like before and after '.' but not able to concatenate it as requried.
08-07-2014 06:20 AM
Did you try running the code. As I stated, the put to format z will pad the numeric out, but as you don't want the zeros then it goes to a character field where a tranwrd is operated on it to get rid of the 0's.
08-07-2014 06:19 AM
That's what my code does, exactly as you wanted in your first post.
08-08-2014 04:54 AM
Your suggested result from the OP (cut&paste) looks like that:
1.1 (2 leading blanks)
1.111 (2 leading blanks)
111.11 (0 leading blanks)
123.341 (0 leading blanks)
1 (4 leading blanks)
231.110 (0 leading blanks)
This is EXACTLY what a proc print of my result into ODS LISTING will show you, buddy.
08-08-2014 05:18 AM
Then you only need this slight variation:
length newvar $ 7;
if indexc(left(invar),'.') = 0
then newvar = put(input(invar,7.),3.);
else substr(newvar,5-indexc(left(invar),'.')) = left(invar);
And next time, take a look at your wanted results before posting.