Since there are no errors in the log, I'm not sure what's going wrong. In the macro, I'm trying to create the variable MAJOR_CAT based on DIAG1. See blow: %LET DATAPULL = DATATWO; %LET OUTDATA = DATAONE; PROC SQL; CREATE TABLE &DATAPULL. AS SELECT /*PULL A BUNCH OF VARIABLES WORKS FINE*/ RUN; %MACRO MAJOR_CAT; %IF DIAG1 =: 'F0' %THEN &MAJOR_CAT. = 'Organic, including symptomatic, mental disorders'; %IF DIAG1 =: 'F1' %THEN &MAJOR_CAT. = 'Mental and behavioural disorders due to psychoative substance use'; %IF DIAG1 =: 'F2' %THEN &MAJOR_CAT. = 'Schizophrena, schizotypal and delusional disorders'; %IF DIAG1 =: 'F3' %THEN &MAJOR_CAT. = 'Mood [affective] disorders'; %IF DIAG1 =: 'F4' %THEN &MAJOR_CAT. = 'Neurotic, stress-related and somatoform disorders'; %IF DIAG1 =: 'F5' %THEN &MAJOR_CAT. = 'Behavioural syndromes associated with physiological disturbances and physical factors'; %IF DIAG1 =: 'F6' %THEN &MAJOR_CAT. = 'Disorders of adult personality and behaviour'; %IF DIAG1 =: 'F7' %THEN &MAJOR_CAT. = 'Mental retardation'; %IF DIAG1 =: 'F8' %THEN &MAJOR_CAT. = 'Disorders of psychological development'; %IF DIAG1 =: 'F90' OR DIAG1 =: 'F91' OR DIAG1 =: 'F92' OR DIAG1 =: 'F93' OR DIAG1 =: 'F94' OR DIAG1 =: 'F95' OR DIAG1 =: 'F96' OR DIAG1 =: 'F97' OR DIAG1 =: 'F98' %THEN &MAJOR_CAT. = 'Behavoural and emotional disorders with onset usually occurring in childhood and adolescence'; %IF DIAG1 =: 'F99' %THEN &MAJOR_CAT. = 'Unspecified mental disorder'; %MEND MAJOR_CAT; /*HERE I CALL THE MACRO AND GET MY &DATAPULL SET SPIT OUT WITH NO MAJOR_CAT VARIABLE*/ DATA &OUTDATA.; SET &DATAPULL.; %MAJOR_CAT; RUN; Below is a non-macro program version of the macro program that works correctly: DATA &OUTDATA.; SET &DATAPULL.; IF DIAG1 =: 'F0' THEN MAJOR_CAT = 'Organic, including symptomatic, mental disorders'; IF DIAG1 =: 'F1' THEN MAJOR_CAT = 'Mental and behavioural disorders due to psychoative substance use'; IF DIAG1 =: 'F2' THEN MAJOR_CAT = 'Schizophrena, schizotypal and delusional disorders'; IF DIAG1 =: 'F3' THEN MAJOR_CAT = 'Mood [affective] disorders'; IF DIAG1 =: 'F4' THEN MAJOR_CAT = 'Neurotic, stress-related and somatoform disorders'; IF DIAG1 =: 'F5' THEN MAJOR_CAT = 'Behavioural syndromes associated with physiological disturbances and physical factors'; IF DIAG1 =: 'F6' THEN MAJOR_CAT = 'Disorders of adult personality and behaviour'; IF DIAG1 =: 'F7' THEN MAJOR_CAT = 'Mental retardation'; IF DIAG1 =: 'F8' THEN MAJOR_CAT = 'Disorders of psychological development'; IF DIAG1 =: 'F90' OR DIAG1 =: 'F91' OR DIAG1 =: 'F92' OR DIAG1 =: 'F93' OR DIAG1 =: 'F94' OR DIAG1 =: 'F95' OR DIAG1 =: 'F96' OR DIAG1 =: 'F97' OR DIAG1 =: 'F98' THEN MAJOR_CAT = 'Behavoural and emotional disorders with onset usually occurring in childhood and adolescence'; IF DIAG1 =: 'F99' THEN MAJOR_CAT = 'Unspecified mental disorder'; RUN;
... View more