05-12-2017 10:58 AM
I used an array to convert the numeric variables to character variables. None of the numeric variables had any formats associated with it but all had a length of 8. The value for non-missing numeric values was 1 and the value of missing numeric values was a period. I applied the character fomat $40. as I need to reformat the values later. However, after conversion of the numeric to character the missing values are being retained as periods and not blanks. Is there a way to have them as blanks after the conversion? Please let me know as soon as possible. Thanks.
Array _character(*) $ 40
DO i=1 to dim(_numeric);
_character(i) = PUT(_numeric(i),8.);
05-12-2017 12:19 PM
@Astounding, chance is very slim, yet possible:
data test; input num; char=put(num,8.); char_1=ifc(num>.,put(num,8.),''); char_2=ifc(not missing(num),put(num,8.),''); cards; 100 . ._ .A .Z ;
05-12-2017 11:14 AM - edited 05-12-2017 11:17 AM
You can change the setting of the MISSING option. Also be careful how you convert to character. Your current use of the PUT() function will cause your character variables to have leading spaces.
2183 %let save=%sysfunc(quote(%qsysfunc(getoption(missing)))); 2184 options missing=' '; 2185 data _null_; 2186 do x=0,1,.,123.456 ; 2187 c1=put(x,8.); 2188 c2=cats(x); 2189 put x= (c1 c2) (= :$quote.) ; 2190 end; 2191 run; x=0 c1=" 0" c2="0" x=1 c1=" 1" c2="1" x= c1="" c2="" x=123.456 c1=" 123" c2="123.456" NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 2192 options missing=&save;
Need further help from the community? Please ask a new question.