ERROR-Retaining Character Values

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 121
Accepted Solution

ERROR-Retaining Character Values

I have been running the following code, but get the note below which tells me that my character values have been converted to numeric. Why does this occurs and (more importantly), how can I retain the variable as a character?

data End;

   array column{9} column1-column9;

   do i=1 to dim(column);

      column(i)='end';

   end;

run;

NOTE: Character values have been converted to numeric values at the places given by: (Line)Smiley SadColumn).


Accepted Solutions
Solution
‎09-08-2014 02:29 PM
Regular Contributor
Posts: 233

Re: ERROR-Retaining Character Values

If you define a numeric variable and assign the result of a character expression to it, SAS tries to convert the character result of the expression to a numeric value and to execute the statement.

If you replace 'end' with number as shown below, the message no longer appears in the log.

data End;
array column{9} column1-column9;

do i=1 to dim(column);
  column(i)=6;
end;
run;

If you want 'end' as is below is code.

data End;
array column{9} $ column1-column9;

do i=1 to dim(column);
  column(i)='end';
end;
run;

View solution in original post


All Replies
Solution
‎09-08-2014 02:29 PM
Regular Contributor
Posts: 233

Re: ERROR-Retaining Character Values

If you define a numeric variable and assign the result of a character expression to it, SAS tries to convert the character result of the expression to a numeric value and to execute the statement.

If you replace 'end' with number as shown below, the message no longer appears in the log.

data End;
array column{9} column1-column9;

do i=1 to dim(column);
  column(i)=6;
end;
run;

If you want 'end' as is below is code.

data End;
array column{9} $ column1-column9;

do i=1 to dim(column);
  column(i)='end';
end;
run;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 138 views
  • 0 likes
  • 2 in conversation