what would cause the sas ERROR: BY variable recipno is not on input data set WORK.DIAG

Reply
Occasional Contributor
Posts: 13

what would cause the sas ERROR: BY variable recipno is not on input data set WORK.DIAG

Given the attached code and error log what would cause the sas ERROR: BY variable recipno is not on input data set WORK.DIAG

the files have already been sorted by recipno before running but there is a problem with the creation of work.diag which is created by the code not a nascent data set

214270

214271  proc sort data=input.inelig;by recipno;run;

NOTE: Input data set is already sorted, no sorting done.

NOTE: PROCEDURE SORT used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

214272  proc sort data=input.step1_medical;by recipno;run;

NOTE: Input data set is already sorted, no sorting done.

NOTE: PROCEDURE SORT used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

214273  proc sort data=input.step1_pharm;by recipno;run;

NOTE: Input data set is already sorted, no sorting done.

NOTE: PROCEDURE SORT used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

214274  libname input "L:\Medical Economics\cdps chronic disease pay system\input";

NOTE: Libref INPUT was successfully assigned as follows:

      Engine:        V9

      Physical Name: L:\Medical Economics\cdps chronic disease pay system\input

214274!                                                                             /*INPUT1*/;

214275  libname output "L:\Medical Economics\cdps chronic disease pay system\output";

NOTE: Libref OUTPUT was successfully assigned as follows:

      Engine:        V9

      Physical Name: L:\Medical Economics\cdps chronic disease pay system\output

214275!                                                                              /*INPUT2*/;

214276

214277  *run the two CDPS programs which will set up the macros to be used later in this code;

214278  %include 'L:\Medical Economics\cdps chronic disease pay system\cdps01.sas'; /*INPUT3*/

214595  %include 'L:\Medical Economics\cdps chronic disease pay system\mrx02.sas'; /*INPUT4*/

214797  proc import

214798      out = weights

214799      datafile = 'L:\Medical Economics\cdps chronic disease pay system\CDPS Virginia

214799! Weights.txt' /*INPUT5*/

214800      dbms = tab replace;

214801      getnames = yes;

214802  run;

214803   /**********************************************************************

214804   *   PRODUCT:   SAS

214805   *   VERSION:   9.2

214806   *   CREATOR:   External File Interface

214807   *   DATE:      25JUN12

214808   *   DESC:      Generated SAS Datastep Code

214809   *   TEMPLATE SOURCE:  (None Specified.)

214810   ***********************************************************************/

214811      data WORK.WEIGHTS                                 ;

214812      %let _EFIERR_ = 0; /* set the ERROR detection macro variable */

214813      infile 'L:\Medical Economics\cdps chronic disease pay system\CDPS Virginia

214813! Weights.txt' delimiter='09'x MISSOVER DSD lrecl=32767 firstobs=2 ;

214814         informat name $9. ;

214815         informat disabled best32. ;

214816         informat tanf_child best32. ;

214817         informat tanf_adult best32. ;

214818         format name $9. ;

214819         format disabled best12. ;

214820         format tanf_child best12. ;

214821         format tanf_adult best12. ;

214822      input

214823                  name $

214824                  disabled

214825                  tanf_child

214826                  tanf_adult

214827      ;

214828      if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */

214829      run;

NOTE: The infile 'L:\Medical Economics\cdps chronic disease pay system\CDPS Virginia

      Weights.txt' is:

      Filename=L:\Medical Economics\cdps chronic disease pay system\CDPS Virginia Weights.txt,

      RECFM=V,LRECL=32767,File Size (bytes)=2420,

      Last Modified=23Apr2012:21:18:36,

      Create Time=08Jun2012:15:19:09

NOTE: 95 records were read from the infile 'L:\Medical Economics\cdps chronic disease pay

      system\CDPS Virginia Weights.txt'.

      The minimum record length was 21.

      The maximum record length was 28.

NOTE: The data set WORK.WEIGHTS has 95 observations and 4 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

95 rows created in WORK.WEIGHTS                              from L:\Medical Economics\cdps

chronic disease pay system\CDPS Virginia Weights.txt.

NOTE: WORK.WEIGHTS data set was successfully created.

NOTE: PROCEDURE IMPORT used (Total process time):

      real time           0.11 seconds

      cpu time            0.07 seconds

214830  proc transpose data = weights

214831      out = weights (drop = _label_ rename = (_name_ = population)) suffix = _fac;

214832      id name;

214833  run;

WARNING: The variable _label_ in the DROP, KEEP, or RENAME list has never been referenced.

NOTE: There were 95 observations read from the data set WORK.WEIGHTS.

NOTE: The data set WORK.WEIGHTS has 3 observations and 96 variables.

NOTE: PROCEDURE TRANSPOSE used (Total process time):

      real time           0.04 seconds

      cpu time            0.03 seconds

214834  data step1;

214835      set input.step1_medical;

214836  run;

NOTE: There were 59466420 observations read from the data set INPUT.STEP1_MEDICAL.

NOTE: The data set WORK.STEP1 has 59466420 observations and 2 variables.

NOTE: DATA statement used (Total process time):

      real time           1:54.15

      cpu time            49.34 seconds

214837  data inelig; set input.inelig; if aid = 'DA'; drop aid; run;

NOTE: There were 188917 observations read from the data set INPUT.INELIG.

NOTE: The data set WORK.INELIG has 15375 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.56 seconds

      cpu time            0.18 seconds

214838  %cdps(DA); *DA for Disabled adults;

NOTE: Format $SGRPFMT is already on the library.

NOTE: Format $SGRPFMT has been output.

NOTE: Format $SNFMT is already on the library.

NOTE: Format $SNFMT has been output.

NOTE: PROCEDURE FORMAT used (Total process time):

      real time           0.17 seconds

      cpu time            0.17 seconds

NOTE: Line generated by the invoked macro "CDPS".

13              * Indicate the existence of a diagnosis in the group variable;

13    ! stage11=put(diag_1,$sgrpfmt.);          stage12=put(diag_2,$sgrpfmt.);

                                                                   ---------

                                                                   48

13    ! stage21=put(stage11,$snfmt.);          stage22=put(stage12,$snfmt.);

13    ! dind{stage21}=1;

WARNING: Variable diag_2 has already been defined as numeric.

ERROR 48-59: The format SGRPFMT was not found or could not be loaded.

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      13:170   13:209

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.DIAGIND may be incomplete.  When this step was stopped there were 0

         observations and 99 variables.

WARNING: Data set WORK.DIAGIND was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      16:39    16:81    16:125   16:169   16:213   17:2     17:46    17:90

NOTE: There were 15375 observations read from the data set WORK.INELIG.

NOTE: The data set WORK.WHO has 15375 observations and 14 variables.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.03 seconds

ERROR: BY variable recipno is not on input data set WORK.DIAGIND.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.STEP2 may be incomplete.  When this step was stopped there were 0

         observations and 123 variables.

WARNING: Data set WORK.STEP2 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.00 seconds

232495  data output.da_med; set step2; run;

NOTE: There were 0 observations read from the data set WORK.STEP2.

NOTE: The data set OUTPUT.DA_MED has 0 observations and 122 variables.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.01 seconds

232496

232497  data inelig; set input.inelig; if aid = 'DC'; drop aid; run;

NOTE: There were 188917 observations read from the data set INPUT.INELIG.

NOTE: The data set WORK.INELIG has 4959 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.03 seconds

232498  %cdps(DC); *DC for Disabled children;

NOTE: Format $SGRPFMT is already on the library.

NOTE: Format $SGRPFMT has been output.

NOTE: Format $SNFMT is already on the library.

NOTE: Format $SNFMT has been output.

NOTE: PROCEDURE FORMAT used (Total process time):

      real time           0.10 seconds

      cpu time            0.10 seconds

NOTE: Line generated by the invoked macro "CDPS".

13              * Indicate the existence of a diagnosis in the group variable;

13    ! stage11=put(diag_1,$sgrpfmt.);          stage12=put(diag_2,$sgrpfmt.);

                                                                   ---------

                                                                   48

13    ! stage21=put(stage11,$snfmt.);          stage22=put(stage12,$snfmt.);

13    ! dind{stage21}=1;

WARNING: Variable diag_2 has already been defined as numeric.

ERROR 48-59: The format SGRPFMT was not found or could not be loaded.

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      13:170   13:209

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.DIAGIND may be incomplete.  When this step was stopped there were 0

         observations and 95 variables.

WARNING: Data set WORK.DIAGIND was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      16:39    16:81    16:125   16:169   16:213   17:2     17:46    17:90

NOTE: There were 4959 observations read from the data set WORK.INELIG.

NOTE: The data set WORK.WHO has 4959 observations and 14 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

ERROR: BY variable recipno is not on input data set WORK.DIAGIND.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.STEP2 may be incomplete.  When this step was stopped there were 0

         observations and 123 variables.

WARNING: Data set WORK.STEP2 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.03 seconds

250147  data output.dc_med; set step2; run;

NOTE: There were 0 observations read from the data set WORK.STEP2.

NOTE: The data set OUTPUT.DC_MED has 0 observations and 122 variables.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.00 seconds

250148

250149  data inelig; set input.inelig; if aid = 'AA'; drop aid; run;

NOTE: There were 188917 observations read from the data set INPUT.INELIG.

NOTE: The data set WORK.INELIG has 40805 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

250150  %cdps(AA); *AA for TANF adults;

NOTE: Format $SGRPFMT is already on the library.

NOTE: Format $SGRPFMT has been output.

NOTE: Format $SNFMT is already on the library.

NOTE: Format $SNFMT has been output.

NOTE: PROCEDURE FORMAT used (Total process time):

      real time           0.17 seconds

      cpu time            0.17 seconds

NOTE: Line generated by the invoked macro "CDPS".

13              * Indicate the existence of a diagnosis in the group variable;

13    ! stage11=put(diag_1,$sgrpfmt.);          stage12=put(diag_2,$sgrpfmt.);

                                                                   ---------

                                                                   48

13    ! stage21=put(stage11,$snfmt.);          stage22=put(stage12,$snfmt.);

13    ! dind{stage21}=1;

WARNING: Variable diag_2 has already been defined as numeric.

ERROR 48-59: The format SGRPFMT was not found or could not be loaded.

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      13:170   13:209

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.DIAGIND may be incomplete.  When this step was stopped there were 0

         observations and 99 variables.

WARNING: Data set WORK.DIAGIND was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      16:39    16:81    16:125   16:169   16:213   17:2     17:46    17:90

NOTE: There were 40805 observations read from the data set WORK.INELIG.

NOTE: The data set WORK.WHO has 40805 observations and 14 variables.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.03 seconds

ERROR: BY variable recipno is not on input data set WORK.DIAGIND.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.STEP2 may be incomplete.  When this step was stopped there were 0

         observations and 113 variables.

WARNING: Data set WORK.STEP2 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.03 seconds

267807  data output.aa_med; set step2; run;

NOTE: There were 0 observations read from the data set WORK.STEP2.

NOTE: The data set OUTPUT.AA_MED has 0 observations and 122 variables.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.03 seconds

267808

267809  data inelig; set input.inelig; if aid = 'AC'; drop aid; run;

NOTE: There were 188917 observations read from the data set INPUT.INELIG.

NOTE: The data set WORK.INELIG has 127778 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.06 seconds

      cpu time            0.03 seconds

267810  %cdps(AC); *AC for TANF children;

NOTE: Format $SGRPFMT is already on the library.

NOTE: Format $SGRPFMT has been output.

NOTE: Format $SNFMT is already on the library.

NOTE: Format $SNFMT has been output.

NOTE: PROCEDURE FORMAT used (Total process time):

      real time           0.18 seconds

      cpu time            0.17 seconds

NOTE: Line generated by the invoked macro "CDPS".

13              * Indicate the existence of a diagnosis in the group variable;

13    ! stage11=put(diag_1,$sgrpfmt.);          stage12=put(diag_2,$sgrpfmt.);

                                                                   ---------

                                                                   48

13    ! stage21=put(stage11,$snfmt.);          stage22=put(stage12,$snfmt.);

13    ! dind{stage21}=1;

WARNING: Variable diag_2 has already been defined as numeric.

ERROR 48-59: The format SGRPFMT was not found or could not be loaded.

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      13:170   13:209

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.DIAGIND may be incomplete.  When this step was stopped there were 0

         observations and 95 variables.

WARNING: Data set WORK.DIAGIND was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

NOTE: Character values have been converted to numeric values at the places given by:

      (Line)Smiley SadColumn).

      16:39    16:81    16:125   16:169   16:213   17:2     17:46    17:90

NOTE: There were 127778 observations read from the data set WORK.INELIG.

NOTE: The data set WORK.WHO has 127778 observations and 14 variables.

NOTE: DATA statement used (Total process time):

      real time           0.37 seconds

      cpu time            0.12 seconds

ERROR: BY variable recipno is not on input data set WORK.DIAGIND.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.STEP2 may be incomplete.  When this step was stopped there were 0

         observations and 113 variables.

WARNING: Data set WORK.STEP2 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.04 seconds

      cpu time            0.03 seconds

285459  data output.ac_med; set step2; run;

NOTE: There were 0 observations read from the data set WORK.STEP2.

NOTE: The data set OUTPUT.AC_MED has 0 observations and 122 variables.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.00 seconds

code:

proc sort data=input.inelig;by recipno;run;

proc sort data=input.step1_medical;by recipno;run;

proc sort data=input.step1_pharm;by recipno;run;

/*final cdps code Virginia Premier May 17th 2012*/

*location of input data;

/*Options Mprint macrogen;

%MRX(AA);

Options Mprint macrogen;

%MRX(AC);

Options Mprint macrogen;

%MRX(DA);

Options Mprint macrogen;

%MRX(DC);

options spool;*/

libname input "L:\Medical Economics\cdps chronic disease pay system\input"; /*INPUT1*/;

libname output "L:\Medical Economics\cdps chronic disease pay system\output";/*INPUT2*/;

*run the two CDPS programs which will set up the macros to be used later in this code;

%include 'L:\Medical Economics\cdps chronic disease pay system\cdps01.sas'; /*INPUT3*/

%include 'L:\Medical Economics\cdps chronic disease pay system\mrx02.sas'; /*INPUT4*/

/*contains sas code cdps01 and child and adult files need to change pointers for this in cdps

sas code for these files to run*/

*import and format the VA-specific CDPS weights which will be applied to the output;

proc import

      out = weights

      datafile = 'L:\Medical Economics\cdps chronic disease pay system\CDPS Virginia Weights.txt' /*INPUT5*/

      dbms = tab replace;

      getnames = yes;

run;

proc transpose data = weights

      out = weights (drop = _label_ rename = (_name_ = population)) suffix = _fac;

      id name;

run;

/***** run CDPS *****/

*CDPS assumes the diagnosis data will be in work.step1;

data step1;

      set input.step1_medical;

run;

*call the macro created in cdps01.sas;

*must be called separately for each population;

*the results are stored in work.step2 which are moved to a permanent dataset on the network;

data inelig; set input.inelig; if aid = 'DA'; drop aid; run;

%cdps(DA); *DA for Disabled adults;

data output.da_med; set step2; run;

data inelig; set input.inelig; if aid = 'DC'; drop aid; run;

%cdps(DC); *DC for Disabled children;

data output.dc_med; set step2; run;

data inelig; set input.inelig; if aid = 'AA'; drop aid; run;

%cdps(AA); *AA for TANF adults;

data output.aa_med; set step2; run;

data inelig; set input.inelig; if aid = 'AC'; drop aid; run;

%cdps(AC); *AC for TANF children;

data output.ac_med; set step2; run;

/***** run MRX *****/

*CDPS assumes the pharmacy data will be in work.step1;

data step1;

      set /*input.step1_rx;*/input.step1_pharm;

run;

*call the macro created in mrx02.sas;

*must be called separately for each population;

*the results are stored in work.step2 which are moved to a permanent dataset on the network;

data inelig; set input.inelig; if aid = 'DA'; run;

%mrx(DA); *DA for Disabled adults;

data output.da_rx; set step2; run;

data inelig; set input.inelig; if aid = 'DC'; run;

%mrx(DC); *DC for Disabled children;

data output.dc_rx; set step2; run;

data inelig; set input.inelig; if aid = 'AA'; run;

%mrx(AA); *AA for TANF adults;

data output.aa_rx; set step2; run;

data inelig; set input.inelig; if aid = 'AC'; run;

%mrx(AC); *AC for TANF children;

data output.ac_rx; set step2; run;

/***** apply weights *****/

*this is the list of variables created by CDPS and MRX. each field contains a 1 or 0 for each member;

%let list = a_under1 a_1_4 a_5_14m a_5_14f a_15_24m a_15_24f a_25_44m a_25_44f a_45_64m a_45_64f a_65 CARVH CARM

                  CARL CAREL PSYH PSYM PSYML PSYL SKCM SKCL SKCVL CNSH CNSM CNSL PULVH PULH PULM PULL GIH GIM GIL DIA1H

                  DIA1M DIA2M DIA2L SKNH SKNL SKNVL RENEH RENVH RENM RENL SUBL SUBVL CANVH CANH CANM CANL DDM DDL GENEL

                  METH METM METVL PRGCMP PRGINC EYEL EYEVL CERL AIDSH INFH HIVM INFM INFL HEMEH HEMVH HEMM HEML

                  MRX1 MRX2 MRX3 MRX4 MRX5 MRX6 MRX7 MRX8 MRX9 MRX10 MRX11 MRX12 MRX13 MRX14 MRX15;

*this is the list of weights that will be multiplied by the ones and zeroes produced by cdps;

%let factors = a_under1_fac a_1_4_fac a_5_14m_fac a_5_14f_fac a_15_24m_fac a_15_24f_fac a_25_44m_fac a_25_44f_fac

                     a_45_64m_fac a_45_64f_fac a_65_fac CARVH_fac CARM_fac CARL_fac CAREL_fac PSYH_fac PSYM_fac PSYML_fac

                     PSYL_fac SKCM_fac SKCL_fac SKCVL_fac CNSH_fac CNSM_fac CNSL_fac PULVH_fac PULH_fac PULM_fac PULL_fac

                     GIH_fac GIM_fac GIL_fac DIA1H_fac DIA1M_fac DIA2M_fac DIA2L_fac SKNH_fac SKNL_fac SKNVL_fac RENEH_fac

                     RENVH_fac RENM_fac RENL_fac SUBL_fac SUBVL_fac CANVH_fac CANH_fac CANM_fac CANL_fac DDM_fac DDL_fac

                     GENEL_fac METH_fac METM_fac METVL_fac PRGCMP_fac PRGINC_fac EYEL_fac EYEVL_fac CERL_fac AIDSH_fac

                     INFH_fac HIVM_fac INFM_fac INFL_fac HEMEH_fac HEMVH_fac HEMM_fac HEML_fac MRX1_fac MRX2_fac

                     MRX3_fac MRX4_fac MRX5_fac MRX6_fac MRX7_fac MRX8_fac MRX9_fac MRX10_fac MRX11_fac MRX12_fac

                     MRX13_fac MRX14_fac MRX15_fac;

*bridge code found in CDPSMRXR.txt;

*is this different in v5.3?;

%macro bridge();

if sum(of CARVH CARM)>0 then do; MRX1=0; MRX2=0; end; if MRX1=1 then do; CARL=0; CAREL=0; MRX2=0; end;

if sum(of CARL CAREL)>0 then MRX2=0;

if sum(of PSYH PSYM PSYML PSYL)>0 then MRX3=0;

if sum(of DIA1H DIA1M DIA2M DIA2L)>0 then MRX4=0;

if sum(of RENEH RENVH)>0 then MRX5=0; if MRX5=1 then do; RENM=0; RENL=0; end;

if HEMEH=1 then MRX6=0; if MRX6=1 then do; HEMVH=0; HEMM=0; HEML=0; end;

if sum(of AIDSH INFH)>0 then do; MRX9=0; MRX8=0; MRX7=0; end; if MRX9=1 then HIVM=0;

if HIVM=1 then do; MRX8=0; MRX7=0; end; if sum(of MRX7 MRX8 MRX9)>0 then do; INFM=0; INFL=0; end;

if sum(of SKCM SKCL SKCVL)>0 then MRX10=0;

if sum(of CANVH CANH CANM)>0 then MRX11=0; if MRX11=1 then CANL=0;

if sum(of CNSH CNSM)>0 then do; MRX12=0; MRX13=0; MRX14=0; end; if MRX12=1 then do; CNSL=0; MRX13=0; MRX14=0; end;

if CNSL=1 then do; MRX13=0; MRX14=0; end; if MRX14=1 then MRX13=0;

if sum(of PULVH PULH PULM PULL)>0 then MRX15=0;

if aidcat='DC' then do; if MRX1=1 then CCARM=1; if MRX6=1 then CHEMEH=1; if MRX9=1 then do; CHIVM=0; CINFM=0; end; if sum(of MRX7 MRX8)=1 then do; CHIVM=1; CINFM=0; end; end;

%mend;

*apply weights for disabled population, both adult and child;

data weight_dac;

      set weights;

      if population = 'disabled';

      drop population;

run;

data da;

      merge output.da_med (in=in1) output.da_rx (in=in2); *merge the ones and zeroes produced by CDPS and MRX above;

      by recipno;

      if _n_ = 1 then set weight_dac; *insert the weights on every record;

    aidcat = 'DA';

      %bridge; *run the bridge code macro;

      *set up arrays to facilitate multiplication of a large list of variables;

      array ind

  • &
  • list. CCARVH CCARM CCNSH CPULVH CPULH CGIH CMETH CHIVM CINFM CHEMEH ;

          array fac

  • &
  • factors. CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                                           CINFM_fac CHEMEH_fac;

          risk_score = intercept_fac; *intercept must be added to every risk score;

          do i = 1 to dim(fac);

                *cycle through all the 1/0s and factors, multiply them together, and add them to the risk score field;

                risk_score = risk_score + ind * fac;

          end;/*end;*/

          drop intercept_fac &factors. i CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                 CINFM_fac CHEMEH_fac aid;

    run;

    data dc;

          merge output.dc_med (in=in1) output.dc_rx (in=in2); *merge the ones and zeroes produced by CDPS and MRX above;

          by recipno;

          if _n_ = 1 then set weight_dac; *insert the weights on every record;

        aidcat = 'DC';

          %bridge; *run the bridge code macro;

          *set up arrays to facilitate multiplication of a large list of variables;

          array ind

  • &
  • list. CCARVH CCARM CCNSH CPULVH CPULH CGIH CMETH CHIVM CINFM CHEMEH ;

          array fac

  • &
  • factors. CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                                           CINFM_fac CHEMEH_fac;

          risk_score = intercept_fac; *intercept must be added to every risk score;

          do i = 1 to dim(fac);

                *cycle through all the 1/0s and factors, multiply them together, and add them to the risk score field;

                risk_score = risk_score + ind * fac;

          end;/*end;*/

          drop intercept_fac &factors. i CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                 CINFM_fac CHEMEH_fac aid;

    run;

    *apply weights for tanf adult population;

    data weight_aa;

          set weights;

          if population = 'tanf_adult';

          drop population;

    run;

    data aa;

          merge output.aa_med (in=in1) output.aa_rx (in=in2); *merge the ones and zeroes produced by CDPS and MRX above;

          by recipno;

          if _n_ = 1 then set weight_aa; *insert the weights on every record;

    aidcat = 'AA';

          %bridge; *run the bridge code macro;

          *set up arrays to facilitate multiplication of a large list of variables;

          array ind

  • &
  • list.;

          array fac

  • &
  • factors.;

          risk_score = intercept_fac; *intercept must be added to every risk score;

          do i = 1 to dim(fac);

                *cycle through all the 1/0s and factors, multiply them together, and add them to the risk score field;

                risk_score = risk_score + ind * fac;

          end;/*end;*/

          drop intercept_fac &factors. i CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                 CINFM_fac CHEMEH_fac aid;

    run;

    *apply weights for tanf child population;

    data weight_ac;

          set weights;

          if population = 'tanf_child';

          drop population;

    run;

    data ac;

          merge output.ac_med (in=in1) output.ac_rx (in=in2); *merge the ones and zeroes produced by CDPS and MRX above;

          by recipno;

          if _n_ = 1 then set weight_ac; *insert the weights on every record;

    aidcat = 'AC';

          %bridge; *run the bridge code macro;

          *set up arrays to facilitate multiplication of a large list of variables;

          array ind

  • &
  • list.;

          array fac

  • &
  • factors.;

          risk_score = intercept_fac; *intercept must be added to every risk score;

          do i = 1 to dim(fac);

                *cycle through all the 1/0s and factors, multiply them together, and add them to the risk score field;

                risk_score = risk_score + ind * fac;

          end;/*end;*/

          drop intercept_fac &factors. i CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                 CINFM_fac CHEMEH_fac aid;

    run;

    *combine results;

    data output.cdps_output;

          set da dc aa ac;

          *if any numeric fields are equal to . then replace them with a 0;

          array num

  • _numeric_;

          do i = 1 to dim(num);

                if num = . then num = 0;

          end;

          drop i;

          rename recipno = membid;

    run;

    proc sort data = output.cdps_output; by membid; run;

    Grand Advisor
    Posts: 9,748

    Re: what would cause the sas ERROR: BY variable recipno is not on input data set WORK.DIAG

    Your code does not show a WORK.DIAG only WORK.DIAGIND.

    Is WORK.DIAG in the INCLUDE files used? Or did you mean to ask about WORK.DIAGIND?

    You post a small section of code with errors generated but not all of it. The note about the the existing file not replaced means that the preivous one, that may have errors, such as missing the desired variables is still in place. Since the first mention of the data set in the posted code is this failure then I would say you need to delete the previous existing version of the dataset and make sure that variable DIAG2 is character since you are using a character format with it. There is obviously much more going on in your CDPS macro that needs to be examined. It may be that you need to make sure the temporary datasets are cleaned up either at the start of the macro or the end so data sets with previous "bad" results aren't still around when invoking the macro with different parameters.

    Post a Question
    Discussion Stats
    • 1 reply
    • 1168 views
    • 0 likes
    • 2 in conversation