Write and run SAS programs in your web browser

ERROR: Variable in list does not match type prescribed for this list.

Reply
Occasional Contributor
Posts: 6

ERROR: Variable in list does not match type prescribed for this list.

Dear SAS users,

 

I have encountered problems in changing variable type from character to numeric.

Specifically, from my PROC CONTENTS results, a few variables have been labelled as categorical when they are numeric in nature, prohibiting the PROC UNIVARIATE to be executed successfully.

For example, the variable Number_of_pregnancies should be numeric, but it has been considered as categorical/character by SAS studio.So, PROC UNIVARIATE cannot proceed with it by showing error in the log file.

The error I have obtained has been illustrated in the attachment along this message, so please have a look at the image attached.

 

Could anyone kindly provide some hints on how to solve this issue?

 

Regards,

Kevin


error_variable_type_prescribed_list.PNG
Super User
Posts: 7,821

Re: ERROR: Variable in list does not match type prescribed for this list.

First of all, I would get rid of all those idiotic 'some_hard_to_read_text'n names and use standard SAS-compatible names. 'XXXXXXXXX'n names only cause confusion and unnecessary work during typing.

'Smokes_(years)'n can easily be replaced by smokes_years without any loss of meaning.

 

If a variable that should be numeric is imported as character, you have to look at the data in the external file and correct the import process.

If a variable can't be corrected there, you have to replace it with a step like this:

%let varname=place_your_varname_here;

data want;
set have (rename=(&varname=__&varname));
&varname = input(__&varname,best.); /* use a proper informat here */
drop __&varname;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 95 views
  • 0 likes
  • 2 in conversation