07-16-2013 11:12 AM
" CATT(REPEAT('0',6-length(EE_LOCATION)),EE_LOCATION); " i have used CATT function to set length of EE_LOCATION to 6.now the problem is that i want to do same work bt dont want to use CATT and REPEAT.any alternative.?
07-16-2013 11:19 AM
IF ee_location is a number you can use z. format.
If character use translate function with 0's replacing spaces, once you've set the length:
data padded_data_dsn; length key $5;
key = translate(right(raw_data),'0',' ');
07-17-2013 05:36 AM
EE_LOCATION = "1111";
WANT = CATT(REPEAT('0',6-length(EE_LOCATION)),EE_LOCATION);
WANT1 = PUT(INPUT(EE_LOCATION,4.),Z7.);
Is this what you want?
07-17-2013 06:42 AM
i have used TRANSLATE now.i want length of EE_LOCATION '6'.but wid with leading zeros..but TRANSLATE and RIGHT function giving me ans with zeros in the end.
07-17-2013 09:21 AM
ee_location="1111"; /* assuming that EE_LOCATION format might be different from $6. if not, you can remove the put() function below and just use ee_location*/
want=(translate(right(put(ee_location, $6.)), '0', ' ');
Not entirely sure that's what you are asking for but anyway. For so long as Right is applied before translate, it should fix your issue of right zero-padding.
07-17-2013 10:40 AM
It works for me, so either there's a mistake in your code or your data has something else in it. Post your code and an example of your data if it doesn't work for you.
length var $6.;
var=translate(right(var), "0", " ");
proc print data=test;run;
07-17-2013 10:45 AM
Another alternative is to use substr() on the left:
put var= newvar=;