Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing numeric to character

Status
Not open for further replies.

sap1958

Technical User
Oct 22, 2009
138
US
ERROR: Variable TEST__CODE has been defined as both character and numeric.
ERROR: Variable PROCEDURES has been defined as both character and numeric.

%macro overall;
data all_invoice;
set
%do i = 1 %to 86; invoice&i
%end;
;
run;
%mend;
%overall;
I attempted to use this macro to bring 86 indvidual files together in 1 report. I get the above named message. Apparently some of the data in the fields are both character and numeric. Do I use something like this to correct it?
TEST_CODE1=put(TEST__CODE);
PROCEDURE=put(PROCEDURES);
Where in the macro would this statememt go (assuming its rigth). The objective is to make both the TEST_CODE and PROCEDURES into character fields
 
You're getting an error as in one or more of the datasets you're setting together has different formats for the same vars.

If all 86 files are meant to be the same and are sourced the same I'd say fix the source.

It could be just 1 of the source files that you need to fix.

To find this you could use the options:

option mprint symbolgen; /* copy this line as is*/

These options wil show in your log what the macro resolves to, so lets say it resolves all the way up to 56, you sort it out and have no other problem's you'd save some work..

Other wise you would need to convert...
 
Infact you can use dictionary tables to combine all the dataset names into one macro variable.

following is the sample code;

proc sql;
select name into: ds_name_list from dictionary.tables where libname = specify_lib_name_here_in_caps separated by ' ';
quit;

you can also make use of dictionary.columns to find out inwhich dataset the column datatype for test__code and procedures are mismatching and accordingly fix the source

sasbuddy
 
You need to make the column either a character or number in all datasets.

It sounds like in your case you want to go to number to character. In that case, you need an input function.

Code:
data x;
set x;
x = 1;
y = input(left(x),$1.);
run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top