BookmarkSubscribeRSS Feed
jdr1
Obsidian | Level 7

Hi SAS Community, 

 

I'm having a difficult time invoking a SAS macro. I'm using SAS 9.4 (Unicode Support). 

 

Here is my code: 

OPTIONS  MPRINT MLOGIC;

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step_v10.sas";

libname LCA 'E:\SecureData\CTL\LCA Manuscript';

 

%LCA_Covariates_3Step_v10(input_data=LCA.finalCO19, postprobs = LCA.my_post4,

id = Actor_ID,

covariates = Gender_name_Male Gender_name_Other Gender_name_nonConforming Race_name_AI Race_name_Asian Race_name_Hispanic Race_name_Other Race_name_White active_rescue age2_14to24 covid ir_flag,

adjustment = BCH,

assignment = modal,

ref_class = 1,

automatically_add_intercept = 1,

) ;

 

Here is the error message from the Log:

 

524  %LCA_Covariates_3Step_v10(input_data=LCA.finalCO19, postprobs = LCA.my_post4,

     -

     180

WARNING: Apparent invocation of macro LCA_COVARIATES_3STEP_V10 not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

525  id = Actor_ID,

526  covariates = Gender_name_Male Gender_name_Other Gender_name_nonConforming Race_name_AI

526! Race_name_Asian Race_name_Hispanic Race_name_Other Race_name_White active_rescue age2_14to24

526! covid ir_flag,

527  adjustment = BCH,

528  assignment = modal,

529  ref_class = 1,

530  automatically_add_intercept = 1,

531  ) ;

 

What am I doing wrong?

14 REPLIES 14
PaigeMiller
Diamond | Level 26

No macro by that name has been defined.

 

The problem could be any one of these:

  • spelling error in the macro name
  • macro truly has not been defined
  • macro has been defined but fatal error in the macro code

and probably many other things.

--
Paige Miller
ballardw
Super User

Somewhere there should be code that starts with the macro definition that would look like

%macro LCA_Covariates_3Step_v10(

and end with %mend; This code defines the macro. If the code with the definition has not been run in the current session, or the code does not reside in an Autocall folder, or the compiled macro is not stored in a repository that the current session can access then the macro is not available.

 

My first guess with most people with limited SAS experience is that the macro definition code has not been executed in the current session.

jdr1
Obsidian | Level 7

Thanks for your quick response. I bet you're correct in that I haven't yet executed the macro definition in the current session. How do I do this? 

 

I have an LCA macro saved in 

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step_v10.sas"; that looks like the following:

 

 

%MACRO LCA_Covariates_3Step(postprobs,

        id,

        Covariates,

        Groups=,

        Assignment=Modal,

        Adjustment=BCH,

        ref_class = 1,

        sampling_weight=,

        automatically_add_intercept = 1

    );    

    TITLE "Using LCA_Covariates_3Step Macro";

    %IF %TRIM("&groups")="" %THEN %DO;

        %LET there_are_groups = 0;

    %END; %ELSE %DO;

        %LET there_are_groups = 1;

    %END;      

    %IF %EVAL(&there_are_groups=1) %THEN %DO;

        DATA Covariates_Macro_Answers; RUN;

        /* Sort the data according to group, and separate into multiple datasets. */

        PROC IML;

            USE &postprobs;

                READ ALL VAR {&Groups} INTO Group;

            CLOSE &postprobs;

        nGroups = MAX(Group);

        CALL SYMPUT("nGroups",CHAR(nGroups));

                   /* the total number of groups; */ 

        %DO this_group=1 %TO &nGroups;            

            DATA _subset_post_group&this_group;

                SET &postprobs;

                IF &Groups=&this_group;

            RUN;

            %LCA_Covariates_3Step_No_Groups(postprobs=_subset_post_group&this_group,

                id=&id,

                Covariates=&Covariates,

                Assignment=&Assignment,

                Adjustment=&Adjustment,

                ref_class=&ref_class,

                sampling_weight=&sampling_weight,

                automatically_add_intercept=&automatically_add_intercept

            );   

            DATA Covariates_Macro_This_Group;

                SET Covariates_Macro_This_Group;

                Group = &this_group;

            RUN;

            DATA Covariates_Macro_Answers;

                SET Covariates_Macro_Answers Covariates_Macro_This_Group;

            RUN;

            DATA Sandwich_Covariance_Grp&this_group;

                SET Weighted_GLogit_Sandwich_Cov;

            RUN;

            DATA Covariates_Macro_Converge_Grp&this_group;

                SET Weighted_Glogit_Convergence;

            RUN;

            PROC DATASETS NOLIST NODETAILS NOWARN;

                DELETE _subset_post_group&this_group;

            QUIT;

        %END;    

    %END; %ELSE %DO;

        %LCA_Covariates_3Step_No_Groups(postprobs=&postprobs,

            id=&id,

            Covariates=&Covariates,

            Assignment=&Assignment,

            Adjustment=&Adjustment,

            ref_class=&ref_class,

            sampling_weight=&sampling_weight,

            automatically_add_intercept=&automatically_add_intercept

        );   

        DATA Covariates_Macro_Answers;

            SET Covariates_Macro_This_Group;

        RUN;            

        DATA Sandwich_Covariance;

            SET Weighted_GLogit_Sandwich_Cov;

        RUN;

        DATA Covariates_Macro_Convergence;

            SET Weighted_Glogit_Convergence;

        RUN;                      

    %END;

    DATA Covariates_Macro_Answers;

        SET Covariates_Macro_Answers;

        WHERE Class IS NOT MISSING;

    RUN;

    %IF %EVAL(&there_are_groups=1) %THEN %DO;

        TITLE "Beta Estimates from LCA_Covariates_3Step Macro";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Group Class Name Beta Std_Err Z P;

        RUN;

        TITLE "Approximate 95% Confidence Intervals for Beta Coefficients";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Group Class Name Beta Lower_CI_Beta Upper_CI_Beta;

        RUN;

        TITLE "Exponentiated Betas (Odds and Odds Ratios) and Approximate 95% Confidence Intervals";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Group Class Name Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta;

        RUN;

    %END; %ELSE %DO;         

        TITLE "Beta Estimates from LCA_Covariates_3Step Macro";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Class Name Beta Std_Err Z P;

        RUN;

        TITLE "Approximate 95% Confidence Intervals for Beta Coefficients";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Class Name Beta Lower_CI_Beta Upper_CI_Beta;

        RUN;

        TITLE "Exponentiated Betas (Odds and Odds Ratios) and Approximate 95% Confidence Intervals";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Class Name Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta;

        RUN;

    %END;

    TITLE;

    PROC DATASETS NOLIST NODETAILS NOWARN;

        DELETE BCHTemp1

               Covariates_Macro_This_Group DataForNlmixed

               ForAnalysis ForAnalysisLong TempDatasetForMacro

               Weighted_GLogit_Coef

               Weighted_GLogit_Sandwich_Cov

               Weighted_Glogit_Convergence

               ;

    QUIT;

%MEND LCA_Covariates_3Step;

 

%MACRO LCA_Covariates_3Step_No_Groups(postprobs,

    id,

    Covariates,

    Assignment,

    Adjustment,

    ref_class,

    sampling_weight,

    automatically_add_intercept

    );     

    /******************************************************************************/

    /***** Count the number of classes in the model using the postprobs dataset ***/

    /******************************************************************************/ 

    DATA bchtemp1; SET &postprobs; RUN;    

    PROC TRANSPOSE DATA=&postprobs OUT=TemporaryDatasetForBCHmacro;

    RUN;

    PROC IML;

        USE TemporaryDatasetForBCHmacro;

            READ ALL VAR {_NAME_} INTO name;

        CLOSE TemporaryDatasetForBCHmacro;

        nClasses = (SUM(SUBSTR(UPCASE(name),1,6)="POSTLC")); /* number of classes */

        CALL SYMPUT("nClasses",CHAR(nClasses));

    QUIT;

    PROC DATASETS NOLIST NOWARN NOPRINT;

        DELETE TemporaryDatasetForBCHmacro;

    RUN;

    %put _all_;

    /******************************************************************************/

    /***** Construct BCH-adjusted class weights to represent class membership *****/

    /******************************************************************************/    

    %CalculateClass_Weights( PostProbsDataset=&postprobs,

                            SubjectID=&id,

                            nClasses=&nClasses,

                            Sampling_Weight=&sampling_weight,

                            Assignment=&Assignment, 

                            Adjustment=&Adjustment);

            /* Outputs datasets Class_Weights and Class_Weights_Long. */

    /*******************************************************************************/

    /***** Append class weights to the dataset for analysis. ***********************/

    /*******************************************************************************/

    DATA ForAnalysis;

        MERGE &postprobs Class_Weights;

        BY &id;

    RUN;

    /*******************************************************************************/

    /***** Add an intercept column to the covariates if appropriate ****************/

    /*******************************************************************************/   

    %IF %EVAL(&automatically_add_intercept>0) %THEN %DO;

        DATA ForAnalysis;

            SET ForAnalysis;

            _Intercept_ = 1;

        RUN;

        %LET Covariates = _Intercept_ &Covariates;

    %END;

    /*******************************************************************************/

    /***** Create long form of dataset with one row per class per participant. *****/

    /*******************************************************************************/

    DATA ForAnalysisLong;

        SET ForAnalysis;

        %DO class = 1 %TO &nClasses;

            LC = &class;    ClassWeight = ClassWeightLC&class; OUTPUT;

        %END;

        DROP %DO class = 1 %TO &nClasses;    

                ClassWeightLC&class

            %END;

        ;

    RUN;

    /*******************************************************************************/

    /***** Estimate the parameters for the underlying parametric weighted **********/

    /***** multinomial generalized logistic regression.                   **********/

    /*******************************************************************************/     

    %DoWeightedGLogit(InputDataset=ForAnalysisLong,

                        OutcomeClass=LC,

                        ref_class=&ref_class,

                        Weight=ClassWeight,

                        Covariates=&Covariates,

                        SubjectID=&id,

                        ObservationID=LC ); 

            /* Outputs datasets Weighted_GLogit_Coef and Weighted_GLogit_Sandwich_Cov. */

    PROC IML;

        USE Weighted_GLogit_Coef;

            READ ALL;

        CLOSE Weighted_GLogit_Coef;

        CovariateIndex = Covariate;

        NamesString = "&Covariates";

        NumCov = 1 + COUNT(NamesString," ");

        Name = J(NROW(CovariateIndex),1,"                                  ");

        DO i = 1 TO NumCov;

            Name[LOC(CovariateIndex=i)] = SCANQ(NamesString,i);

        END;

        Beta = Estimate;

        Exp_Beta = EXP(Beta);

        Upper_CI_Beta = Beta + 1.96 * Std_Err;

        Lower_CI_Beta = Beta - 1.96 * Std_Err;

        Upper_CI_Exp_Beta = EXP(Upper_CI_Beta);

        Lower_CI_Exp_Beta = EXP(Lower_CI_Beta);

        Z = Estimate / Std_Err;

        p = 1 - PROBNORM(ABS(Z));

        CREATE Covariates_Macro_This_Group VAR {Name Class Beta Std_Err Z p

                                             Lower_CI_Beta Upper_CI_Beta

                                             Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta};

            APPEND;

        CLOSE Covariates_Macro_This_Group;

    QUIT;

%MEND LCA_Covariates_3Step_No_Groups;

%MACRO DoWeightedGLogit(InputDataset=,

                    OutcomeClass=,

                         ref_class=1,

                    Weight=,

                    Covariates=,

                    SubjectID=,

                         ObservationID=,

                    RegularizationConstantExp=0,

                    RegularizationConstantForCov=0,

                         RegularizationConstantForSE=0);

    PROC IML;

        USE &InputDataset;

             READ ALL VAR {&OutcomeClass} INTO Y;

            READ ALL VAR {&Weight} INTO W;

            READ ALL VAR {&Covariates} INTO XMatrix;

            READ ALL VAR {&SubjectID} INTO id;

        CLOSE &InputDataset;

        numCovariates  = NCOL(XMatrix);

        numClasses = Y[<>];

        CALL SYMPUT("numCovariates",(CHAR(numCovariates)));

        CALL SYMPUT("numClasses",(CHAR(numClasses)));

        DataForNlmixedAsMatrix = id || W || Y || XMatrix;

        VariableNames = "id" || "W" || "Y" || ("X1":"X&numCovariates"); 

        CREATE DataForNlmixed FROM DataForNlmixedAsMatrix [COLNAME=VariableNames];

            APPEND FROM DataForNlmixedAsMatrix ;

        CLOSE DataForNlmixed;

    QUIT;    

    ODS EXCLUDE ALL; RUN;

    ODS NORESULTS; RUN;

    PROC NLMIXED DATA=DataForNlmixed COV START HESS METHOD=GAUSS TECH=NRRIDG MAXITER=500

MAXFUNC=1000;

        PARMS %DO k = 1 %TO %EVAL(&numCovariates);

                %DO c = 1 %TO %EVAL(&numClasses);

                         %IF %EVAL(&c ^= &Ref_Class) %THEN %DO;

                         b&k&c = 0 

                         %END;

                %END;

              %END; ;

        %DO c = 1 %TO %EVAL(&numClasses);

               %IF %EVAL(&c ^= &Ref_Class) %THEN %DO;

            eta&c = b1&c*X1

                    %IF %EVAL(&numCovariates>1) %THEN %DO;

                        %DO  k = 2 %TO &numCovariates;

                            + b&k&c*X&k

                        %END;

                    %END;

                  ;

            expEta&c = EXP(eta&c + &RegularizationConstantExp);

               %END; %ELSE %DO;

             eta&c = 0;

               %END;

        %END;

        denominator = 1

                %DO c = 1 %TO %EVAL(&numClasses);

                         %IF %EVAL(&c ^= &Ref_Class) %THEN %DO;

                          + expEta&c

                    %END;

            %END; ;

        %DO c = 1 %TO %EVAL(&numClasses);

               %IF %EVAL(&c ^= &Ref_Class) %THEN %DO;

                 IF Y=&c THEN likelihood = expEta&c/denominator;

               %END; %ELSE %DO;

                  IF Y=&c THEN likelihood = 1/denominator;

               %END;

        %END;

          SumSquaredBetas = 0;

        %DO c = 1 %TO %EVAL(&numClasses);

               %IF %EVAL(&c ^= &Ref_Class) %THEN %DO;

               SumSquaredBetas = SumSquaredBetas + (b1&c)**2

                    %IF %EVAL(&numCovariates>1) %THEN %DO;

                        %DO  k = 2 %TO &numCovariates;

                            + (b&k&c)**2

                        %END;

                    %END;;

               %END;

        %END;

        loglikelihood = W *LOG(likelihood) ;

        MODEL Y ~ GENERAL(loglikelihood);

        ODS OUTPUT PARAMETERESTIMATES=Weighted_GLogit_Coef

                     CONVERGENCESTATUS=Weighted_Glogit_Convergence; 

    RUN; 

    PROC PRINT DATA=Weighted_GLogit_Coef; RUN;

    DATA Weighted_GLogit_Coef;

        SET Weighted_GLogit_Coef;

        Row = _N_;

        Covariate = INT((Row-1)/(&numClasses-1))+1;

        Class = Row-(Covariate-1)*(&numClasses-1);

          IF (Class=>&ref_class) THEN Class = Class + 1; /*skip reference class */

        DROP Row;

        Std_Err = .;

        KEEP Covariate Class Estimate Std_Err;

    RUN;

    PROC PRINT DATA=Weighted_GLogit_Coef; RUN;

    PROC SORT DATA=Weighted_GLogit_Coef;

        BY Class Covariate;

    RUN;

    PROC PRINT DATA=Weighted_GLogit_Coef; RUN;    

    DATA TempDatasetForMacro; SET &InputDataset;

        BY &SubjectID;

        RETAIN BCHMacroIntID 0;

        IF first.&SubjectID THEN BCHMacroIntID = BCHMacroIntID + 1;

            /* This creates a recoded version of the subject ID variable,

               called "BCHMacroIntID," that is composed of consecutive

               integers starting with 1.  This makes it possible for some

               of the code in the macro to be simpler than if subjects could

               have anything for ID's.

             See http://www.ats.ucla.edu/stat/sas/faq/enumerate_id.htm; */

        OUTPUT;

    RUN;    

    PROC IML;

         /* Might be able to improve memory efficiency using the FREE command

           or the SYMSIZE and WORKSIZE options? */

        USE  Weighted_GLogit_Coef;

            READ ALL VAR {Covariate Class Estimate};

        CLOSE Weighted_GLogit_Coef;

          USE TempDatasetForMacro;

            READ ALL VAR {&OutcomeClass} INTO Y;

            READ ALL VAR {&Weight} INTO W;

            READ ALL VAR {&Covariates} INTO XMatrix;

            READ ALL VAR {BCHMacroIntID} INTO ClusterId;

               READ ALL VAR {&ObservationID} INTO MemberID;

        CLOSE TempDatasetForMacro;

        p  = NCOL(XMatrix);

        ntotal = NROW(Y);

        nsub = ClusterID[<>];  /* assumes indexing starts at 1 for this variable */

        PRINT ClusterID;

        PRINT ntotal nsub;

        m = ntotal / nsub;  /* assumes equal cluster sizes */

        n = ntotal / m; /* assumes equal cluster sizes */

        nc = Y[<>];  /* Number of classes.   */

        YAsMatrix = J(n*m,nc,0);

        DO c = 1 TO nc;

            IF SUM(Y=c)>0 THEN DO;

                whichrows = LOC(Y=c)`;

                YAsMatrix[whichrows,c] = 1;

            END;

        END;

        CoefAsVector = Estimate;

        ModelInformationMatrix = J((nc-1)*p,(nc-1)*p,0);

        TotalScoreVector = J((nc-1)*p,1,0);

        EmpiricalCovOfScore = J(p*(nc-1),p*(nc-1),0);

        CoefAsMatrix = SHAPE(CoefAsVector,nc-1)`;

        ref_class = &ref_class;          

        IF (ref_class = 1) THEN DO;

             Nonref_classes = 2:nc;

        END;

        IF (ref_class = nc) THEN DO;

             Nonref_classes = 1:(nc-1);

        END;

        IF ((ref_class >1) & (ref_class < nc)) THEN DO;

            Nonref_classes = (1:(ref_class-1)) || ((ref_class+1):nc);

        END;

        DO i = 1 TO n;

            ScoreVector = J((nc-1)*p,1,0);

            DO j = 1 TO m;                 

                wij = w[LOC(ClusterID=i & MemberID=j)]; * Assumes there is only one such entry. ;

                yij = YasMatrix[LOC(ClusterID=i & MemberID=j),]`;

                xij = XMatrix[LOC(ClusterID=i & MemberID=j),];

                eta = J(nc,1,0);

                eta[Nonref_classes] =  xij*CoefAsMatrix;

                eta = (eta <> -20) >< +20;

                eta = eta + &RegularizationConstantForSE;

                expEta = EXP(eta);

                piij = expEta / expEta[+];

                Mij = DIAG(piij[Nonref_classes]) - piij[Nonref_classes]*piij[Nonref_classes]`;                

                BigXij = (I(nc-1) @ xij)`;

                ScoreVector = ScoreVector + wij*BigXij*(yij[Nonref_classes]-piij[Nonref_classes]);

                ModelInformationMatrix = ModelInformationMatrix + wij*BigXij*Mij*BigXij`;

            END;

            TotalScoreVector = TotalScoreVector + ScoreVector;

            EmpiricalCovOfScore = EmpiricalCovOfScore + ScoreVector*ScoreVector`;

        END;         

        CoefAsVectorOld = CoefAsVector; 

        lambda = &RegularizationConstantForcov*(VECDIAG(ModelInformationMatrix))[+];

          NaiveCovCoef = INV(ModelInformationMatrix+lambda*I(NROW(ModelInformationMatrix)));

        CoefAsVector = CoefAsVector + NaiveCovCoef*TotalScoreVector;

        MaxAbsDev = (ABS(CoefAsVector - CoefAsVectorOld))[<>];

        CorrectionFactor = (n/(n-1))*((n*m-1)/(n*m-(nc-1)*p)); 

        * In SAS PROC SURVEYLOGISTIC, the option VADJUST=NONE uses n/(n-1). 

        *   The option VADJUST=DF uses (n/(n-1))*((n*m-1)/(n*m-(nc-1)*p)). ;

        SandwichCov = NaiveCovCoef` * (CorrectionFactor*EmpiricalCovOfScore) * NaiveCovCoef;

        IF (VECDIAG(SandwichCov)[><]>0) THEN DO;          

            Std_Err  = SQRT(VECDIAG(SandwichCov));

          END; ELSE DO;

              Std_Err = J(NROW(SandwichCov),1,.);

          END;

        EDIT Weighted_GLogit_Coef;

            REPLACE ALL VAR {Std_Err };

        CLOSE Weighted_GLogit_Coef;

        CREATE Weighted_GLogit_Sandwich_Cov FROM SandwichCov;

            APPEND FROM SandwichCov;

        CLOSE Weighted_GLogit_Sandwich_Cov;

    QUIT;

    ODS EXCLUDE NONE; RUN;

    ODS RESULTS; RUN;

%MEND DoWeightedGLogit;

%MACRO CalculateClass_Weights(PostProbsDataset,

                             SubjectID,   

                             nClasses,

                             Sampling_Weight,

                             Assignment,  /* modal or proportional */

                             Adjustment  /* BCH or none */

                             );

    PROC IML;     

         Assignment = LOWCASE(TRIM("&Assignment"));

         Adjustment = LOWCASE(TRIM("&Adjustment"));

          IF (Assignment^="modal" & Assignment^="proportional") THEN DO;

               PRINT ("Assignment option not recognized:");

               PRINT(Assignment);

          END;

          IF (Adjustment^="bch" & Adjustment^="none") THEN DO;

               PRINT ("Adjustment option not recognized:");

               PRINT(Adjustment);

          END;

        /* Calculate BCH weights.*/    

        USE &PostProbsDataset;

            READ ALL VAR {&SubjectID

                            %DO class = 1 %TO &nClasses;

                                PostLC&class

                            %END;

                          &sampling_weight Best};

        CLOSE &PostProbsDataset;

        PostLC = PostLC1     %DO class = 2 %TO &nClasses;

                        || PostLC&class

                    %END;  ;  /* concatenate the vectors into a matrix */

          IsBestLC = (Best=1)      %DO class = 2 %TO &nClasses;

                              || (Best=&class)

                         %END; ;

          UnadjustedWeights = J(NROW(IsBestLC),&nClasses,.);

          IF (Assignment="modal") THEN DO;

               UnadjustedWeights = IsBestLC;

          END; ELSE DO;

               UnadjustedWeights = PostLC;

          END;                         

          IF (LENGTH(LOWCASE(TRIM("_&sampling_weight")))>1) THEN DO;

                DO class = 1 TO &nClasses;

                    UnadjustedWeights[,class] = (&sampling_weight + 0)#UnadjustedWeights[,class];

                            /* adding zero is a weird work-around to get around a macro language limitation*/

               END;

          END; ELSE DO;

          END;

          IF (Adjustment="bch") THEN DO;

                D = J(&nClasses,&nClasses,.); 

               /* Based on Bolck, Croon and Hagenaars (2004, Political

                    Analysis), Vermunt (2010, Political Analysis) and Bakk and Vermunt (2016,

                    Structural Equation Modeling), we will define D so that D(t,s) is the

                    probability of being assigned to class s, for a subject whose

                    true class is t. */

               DO t = 1 TO &nClasses;

                    DO s = 1 TO &nClasses;

                         D[t,s] = ((PostLC[,t] # UnadjustedWeights[,s])[+]) / (PostLC[+,t]);

                    END;

               END; 

               Class_Weights = UnadjustedWeights * INV(D); 

               /* These are the BCH weights.  */

          END; ELSE DO;

               Class_Weights = UnadjustedWeights;

          END; 

          %DO class = 1 %TO &nClasses;

               ClassWeightLC&class = Class_Weights[,&class];

          %END;

        CREATE Class_Weights VAR {&SubjectID %DO class = 1 %TO &nClasses;

                ClassWeightLC&class 

                %END;};

            APPEND ;

        CLOSE Class_Weights;

    QUIT;

     DATA Class_Weights_Long;

          SET Class_Weights;

         %DO class = 1 %TO &nClasses;

               Class = &class;

               ClassWeight = ClassWeightLC&class;

               OUTPUT;

          %END;    

          KEEP &SubjectID Class ClassWeight;

     RUN;

%MEND CalculateClass_Weights;

 

 

PaigeMiller
Diamond | Level 26

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step_v10.sas"; that looks like the following:

If you look in the code inside that file, you will see there is NO macro by the name %LCA_Covariates_3Step_v10. It doesn't matter that LCA_Covariates_3Step_v10 is the name of the .sas file, as this does not make it the name of a macro.

 

So you cannot call a macro with that name.

 

There are several other macros with other names in the file, you can call any one of those, and then that should work. OR you can define %LCA_Covariates_3Step_v10 and then you can call it

 

--
Paige Miller
jdr1
Obsidian | Level 7

Ah, got it. I was under the impression that by directing SAS to read the macro code from the path using a SAS %INCLUDE that all code within the larger macro file would automatically run. Is there not a way to do that? 

PaigeMiller
Diamond | Level 26

@jdr1 wrote:

Ah, got it. I was under the impression that by directing SAS to read the macro code from the path using a SAS %INCLUDE that all code within the larger macro file would automatically run. Is there not a way to do that? 


I don't think you have "got it". Yes, all the code in the .sas file is included and run. But there is no macro by the name %LCA_Covariates_3Step_v10 in that file. That's why your code doesn't run. SAS can't run a macro %LCA_Covariates_3Step_v10 if it doesn't exist.

 

SAS can run other macros that are in that file, but those have different names. You have to call them by their actual names. Do you want to run one of the other macros? Those will run properly (assuming no syntax errors).

--
Paige Miller
AMSAS
SAS Super FREQ

What @PaigeMiller said
Looking at the code you pasted there are only 4 macros defined:

 

%MACRO LCA_Covariates_3Step
%MACRO LCA_Covariates_3Step_No_Groups
%MACRO DoWeightedGLogit
%MACRO CalculateClass_Weights

 

None are called "LCA_Covariates_3Step_v10"

jdr1
Obsidian | Level 7

Macros are difficult for me. Even if I rename the macro to reflect the first name of the macro within the file, I do not get output???

 

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step.sas";

%LCA_Covariates_3Step(input_data=LCA.finalCO19, postprobs = LCA.my_post4,

id = Actor_ID,

covariates = Gender_name_Male Gender_name_Other Gender_name_nonConforming Race_name_AI Race_name_Asian Race_name_Hispanic Race_name_Other Race_name_White active_rescue age2_14to24 covid ir_flag,

adjustment = BCH,

assignment = modal,

ref_class = 1,

automatically_add_intercept = 1

) ;

AMSAS
SAS Super FREQ

1) What is the name of the file that contains the macros? 
%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step_v10.sas";

or 

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step.sas";

 

2) What is the name of the macro you want to run?

LCA_Covariates_3Step_v10

or

LCA_Covariates_3Step

 

I think you are confusing the file name with the macro name
Please post the full log with options mprint mlogic symbolgen ;

PaigeMiller
Diamond | Level 26

@jdr1 wrote:

Macros are difficult for me. Even if I rename the macro to reflect the first name of the macro within the file, I do not get output???

 

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step.sas";

%LCA_Covariates_3Step(input_data=LCA.finalCO19, postprobs = LCA.my_post4,

id = Actor_ID,

covariates = Gender_name_Male Gender_name_Other Gender_name_nonConforming Race_name_AI Race_name_Asian Race_name_Hispanic Race_name_Other Race_name_White active_rescue age2_14to24 covid ir_flag,

adjustment = BCH,

assignment = modal,

ref_class = 1,

automatically_add_intercept = 1

) ;


And what error do you get? Do you get a different error now?


The bottom line is that the name of the file does not imply there is a macro of the same name. I think this is the point you are missing.

 

Furthermore, having a macro with a given name does not imply the file name. You have to have a macro inside the file of the exact same name of the macro that you are calling in your SAS code. The actual SAS file can be named aaabbbccc.sas, that is irrelevant to the entire discussion, it is only the names of the macros in the file that must match the name of the macro you are calling in the SAS code.

--
Paige Miller
Astounding
PROC Star

Once you get the naming issue resolved (and it is a real issue), you also need to remove a comma when trying to call the macro.  Right now, your attempts to call the macro end (improperly) with

 

, );
jdr1
Obsidian | Level 7

I sincerely appreciate all contributions made in this thread. I really need to master running macros. 

 

I went back to the drawing board and made the changes suggested. I ran the code and didn't receive any errors, but didn't receive output. 

 

*******************************************************Here is the code I ran:

 

%INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step_v10.sas";

%LCA_Covariates_3Step (

input_data = LCA.finalCO19,

postprobs = LCA.my_post4,

id = Actor_ID,

covariates = Gender_name_Male Gender_name_Other Gender_name_nonConforming Race_name_AI Race_name_Asian Race_name_Hispanic Race_name_Other Race_name_White active_rescue age2_14to24 covid ir_flag,

);

 

*******************************************************And I was trying to map to this macro:

%MACRO LCA_Covariates_3Step(postprobs,

        id,

        Covariates,

        Groups=,

        Assignment=Modal,

        Adjustment=BCH,

        ref_class = 1,

        sampling_weight=,

        automatically_add_intercept = 1

    );    

    TITLE "Using LCA_Covariates_3Step Macro";

    %IF %TRIM("&groups")="" %THEN %DO;

        %LET there_are_groups = 0;

    %END; %ELSE %DO;

        %LET there_are_groups = 1;

    %END;      

    %IF %EVAL(&there_are_groups=1) %THEN %DO;

        DATA Covariates_Macro_Answers; RUN;

        /* Sort the data according to group, and separate into multiple datasets. */

        PROC IML;

            USE &postprobs;

                READ ALL VAR {&Groups} INTO Group;

            CLOSE &postprobs;

        nGroups = MAX(Group);

        CALL SYMPUT("nGroups",CHAR(nGroups));

                   /* the total number of groups; */ 

        %DO this_group=1 %TO &nGroups;            

            DATA _subset_post_group&this_group;

                SET &postprobs;

                IF &Groups=&this_group;

            RUN;

            %LCA_Covariates_3Step_No_Groups(postprobs=_subset_post_group&this_group,

                id=&id,

                Covariates=&Covariates,

                Assignment=&Assignment,

                Adjustment=&Adjustment,

                ref_class=&ref_class,

                sampling_weight=&sampling_weight,

                automatically_add_intercept=&automatically_add_intercept

            );   

            DATA Covariates_Macro_This_Group;

                SET Covariates_Macro_This_Group;

                Group = &this_group;

            RUN;

            DATA Covariates_Macro_Answers;

                SET Covariates_Macro_Answers Covariates_Macro_This_Group;

            RUN;

            DATA Sandwich_Covariance_Grp&this_group;

                SET Weighted_GLogit_Sandwich_Cov;

            RUN;

            DATA Covariates_Macro_Converge_Grp&this_group;

                SET Weighted_Glogit_Convergence;

            RUN;

            PROC DATASETS NOLIST NODETAILS NOWARN;

                DELETE _subset_post_group&this_group;

            QUIT;

        %END;    

    %END; %ELSE %DO;

        %LCA_Covariates_3Step_No_Groups(postprobs=&postprobs,

            id=&id,

            Covariates=&Covariates,

            Assignment=&Assignment,

            Adjustment=&Adjustment,

            ref_class=&ref_class,

            sampling_weight=&sampling_weight,

            automatically_add_intercept=&automatically_add_intercept

        );   

        DATA Covariates_Macro_Answers;

            SET Covariates_Macro_This_Group;

        RUN;            

        DATA Sandwich_Covariance;

            SET Weighted_GLogit_Sandwich_Cov;

        RUN;

        DATA Covariates_Macro_Convergence;

            SET Weighted_Glogit_Convergence;

        RUN;                      

    %END;

    DATA Covariates_Macro_Answers;

        SET Covariates_Macro_Answers;

        WHERE Class IS NOT MISSING;

    RUN;

    %IF %EVAL(&there_are_groups=1) %THEN %DO;

        TITLE "Beta Estimates from LCA_Covariates_3Step Macro";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Group Class Name Beta Std_Err Z P;

        RUN;

        TITLE "Approximate 95% Confidence Intervals for Beta Coefficients";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Group Class Name Beta Lower_CI_Beta Upper_CI_Beta;

        RUN;

        TITLE "Exponentiated Betas (Odds and Odds Ratios) and Approximate 95% Confidence Intervals";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Group Class Name Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta;

        RUN;

    %END; %ELSE %DO;         

        TITLE "Beta Estimates from LCA_Covariates_3Step Macro";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Class Name Beta Std_Err Z P;

        RUN;

        TITLE "Approximate 95% Confidence Intervals for Beta Coefficients";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Class Name Beta Lower_CI_Beta Upper_CI_Beta;

        RUN;

        TITLE "Exponentiated Betas (Odds and Odds Ratios) and Approximate 95% Confidence Intervals";

        PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

            VAR Class Name Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta;

        RUN;

    %END;

    TITLE;

    PROC DATASETS NOLIST NODETAILS NOWARN;

        DELETE BCHTemp1

               Covariates_Macro_This_Group DataForNlmixed

               ForAnalysis ForAnalysisLong TempDatasetForMacro

               Weighted_GLogit_Coef

               Weighted_GLogit_Sandwich_Cov

               Weighted_Glogit_Convergence

               ;

    QUIT;

%MEND LCA_Covariates_3Step;

 

*******************************************************Here is what the log said:

1671  OPTIONS  MPRINT MLOGIC;

1672  %INCLUDE "E:\SecureData\CTL\LCA Manuscript\3step_macro\LCA_Covariates_3Step_v10.sas";

1673  %LCA_Covariates_3Step (

1674      input_data = LCA.finalCO19,

1675      postprobs = LCA.my_post4,

1676      id = Actor_ID,

1677      covariates = Gender_name_Male Gender_name_Other Gender_name_nonConforming Race_name_AI

1677! Race_name_Asian Race_name_Hispanic Race_name_Other Race_name_White active_rescue age2_14to24

1677! covid ir_flag,

1678  );

ballardw
Super User

One of the unfortunate side effects of bad macro coding is that you can leave the SAS session unstable.

Since your last log shows nothing after the macro call with Options Mprint turned on it makes me strongly believe that your previous errors have left your session unstable and the code wasn't actually submitted because somewhere SAS as expecting something, and who knows what, to complete previous stuff.

 

Save your code. Close down your SAS session and reattempt the code.

However if one of your other macros still has definition issues you may find this happening. Possibly a lot.

 

Also, do you actually have SAS/IML installed? If not the Proc Iml call will throw errors as well and likely have  issues because you would not have some of the output sets populated.

 

 

jdr1
Obsidian | Level 7

I ran the sample code for this particular macro and was able to make it work. 

 

Data snippet:

 

Obs

actor_id

abuse

bereavement

bully

depressed

isolated

relationship

self_harm

stress_anxiety

substance

suicide

Other

nonConfor

AI

Asian

Hispanic

GenOther

White

age14to24

COVID

irflag

1

169

1

1

1

1

1

1

1

2

1

1

1

1

1

1

1

1

1

0

1

1

2

499

1

2

1

2

1

2

1

2

1

2

1

1

1

1

1

1

0

0

1

1

3

547

1

1

1

2

1

1

2

2

1

1

1

1

1

1

0

1

1

0

1

1

4

615

2

2

1

2

2

2

2

2

2

2

1

1

1

1

1

1

0

0

0

1

5

924

2

1

1

1

1

2

1

1

1

1

1

1

1

1

1

1

0

0

1

1

6

930

1

1

1

2

2

2

2

2

1

2

1

1

1

1

1

1

0

0

1

1

7

1075

2

1

1

2

1

2

1

1

1

1

1

1

1

0

1

1

1

0

1

1

8

1129

1

1

1

2

2

2

1

1

1

2

1

1

1

1

1

1

0

0

1

1

9

1193

1

1

1

2

2

1

1

2

1

1

1

1

1

1

1

1

0

0

1

1

10

1197

1

1

2

2

1

1

1

2

1

1

1

1

1

1

1

1

0

0

1

1

11

1310

2

2

1

2

2

2

2

2

1

2

1

1

0

1

1

1

1

0

1

0

12

1367

1

2

1

1

1

1

1

1

1

1

1

1

1

1

1

1

0

0

1

1

13

1651

1

1

1

2

1

2

1

2

1

1

1

1

1

1

1

1

0

0

1

1

14

1695

1

1

1

1

2

2

2

2

1

1

1

1

1

1

1

1

0

0

0

1

15

1706

1

1

1

2

2

1

1

2

1

1

1

1

1

0

1

1

1

0

0

1

16

1723

1

1

1

2

2

2

2

1

1

2

1

1

1

1

1

1

0

0

1

1

17

1861

2

2

2

2

2

2

2

2

1

2

1

1

1

1

1

1

0

0

0

1

18

2011

2

2

1

2

2

2

2

2

1

2

1

1

1

1

1

1

0

0

0

0

19

2022

1

1

1

2

1

1

1

1

1

2

1

1

1

1

1

1

0

0

1

1

20

2050

1

1

1

2

2

1

2

2

1

2

1

1

1

1

1

1

0

0

1

1

21

2060

1

1

1

2

1

1

1

1

1

1

1

1

1

1

1

1

0

0

1

1

22

2167

1

1

1

2

2

1

2

2

1

2

1

1

1

1

1

1

0

0

1

1

23

2206

2

1

1

2

2

2

2

2

2

2

1

1

1

1

1

1

0

0

1

1

24

2366

1

2

1

2

2

1

2

2

1

2

1

0

1

1

1

1

0

0

1

1

 

I ran this macro code:

%LCA_Covariates_3Step(postprobs = my_post4,

id = actor_id,

covariates =  Other nonConfor AI Asian Hispanic genOther White age14to24 covid irflag);

*Covariates = Male Other nonConfor AI Asian Hispanic Other White GenOther age14to24 covid irflag

**code calling the 2nd macro w

And keep encountering an error stating:

ERROR: OTHER is not in the scope of variables for the data set.

 

SAS log:

MLOGIC(LCA_COVARIATES_3STEP):  Parameter COVARIATES has value Other nonConfor AI Asian Hispanic

      genOther White age14to24 covid irflag

MLOGIC(LCA_COVARIATES_3STEP):  Parameter GROUPS has value

MLOGIC(LCA_COVARIATES_3STEP):  Parameter ASSIGNMENT has value Modal

MLOGIC(LCA_COVARIATES_3STEP):  Parameter ADJUSTMENT has value BCH

MLOGIC(LCA_COVARIATES_3STEP):  Parameter REF_CLASS has value 1

MLOGIC(LCA_COVARIATES_3STEP):  Parameter SAMPLING_WEIGHT has value

MLOGIC(LCA_COVARIATES_3STEP):  Parameter AUTOMATICALLY_ADD_INTERCEPT has value 1

MPRINT(LCA_COVARIATES_3STEP):   TITLE "Using LCA_Covariates_3Step Macro";

MLOGIC(TRIM):  Beginning execution.

MLOGIC(TRIM):  This macro was compiled from the autocall file C:\Program

      Files\SASHome\SASFoundation\9.4\core\sasmacro\trim.sas

MLOGIC(TRIM):  Parameter VALUE has value ""

MLOGIC(TRIM):  %LOCAL  I

MLOGIC(TRIM):  %DO loop beginning; index variable I; start value is 2; stop value is 1; by value is

      -1.

MLOGIC(TRIM):  %IF condition %qsubstr(&value,&i,1) ne is TRUE

MLOGIC(TRIM):  %GOTO trimmed (label resolves to TRIMMED).

MLOGIC(TRIM):  %IF condition &i>0 is TRUE

MLOGIC(TRIM):  Ending execution.

MLOGIC(LCA_COVARIATES_3STEP):  %IF condition %TRIM("&groups")="" is TRUE

MLOGIC(LCA_COVARIATES_3STEP):  %LET (variable name is THERE_ARE_GROUPS)

MLOGIC(LCA_COVARIATES_3STEP):  %IF condition %EVAL(&there_are_groups=1) is FALSE

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Beginning execution.

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter POSTPROBS has value my_post4

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter ID has value actor_id

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter COVARIATES has value Other nonConfor AI Asian

      Hispanic genOther White age14to24 covid irflag

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter ASSIGNMENT has value Modal

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter ADJUSTMENT has value BCH

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter REF_CLASS has value 1

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter SAMPLING_WEIGHT has value

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Parameter AUTOMATICALLY_ADD_INTERCEPT has value 1

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DATA bchtemp1;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   SET my_post4;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   RUN;

 

NOTE: There were 157274 observations read from the data set WORK.MY_POST4.

NOTE: The data set WORK.BCHTEMP1 has 157274 observations and 16 variables.

NOTE: DATA statement used (Total process time):

      real time           0.16 seconds

      cpu time            0.10 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   PROC TRANSPOSE DATA=my_post4

OUT=TemporaryDatasetForBCHmacro;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   RUN;

 

NOTE: There were 157274 observations read from the data set WORK.MY_POST4.

NOTE: The data set WORK.TEMPORARYDATASETFORBCHMACRO has 16 observations and 157276 variables.

NOTE: PROCEDURE TRANSPOSE used (Total process time):

      real time           0.78 seconds

      cpu time            0.71 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   PROC IML;

NOTE: IML Ready

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   USE TemporaryDatasetForBCHmacro;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   READ ALL VAR {_NAME_} INTO name;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   CLOSE TemporaryDatasetForBCHmacro;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   nClasses = (SUM(SUBSTR(UPCASE(name),1,6)="POSTLC"));

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   CALL SYMPUT("nClasses",CHAR(nClasses));

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   QUIT;

NOTE: Exiting IML.

NOTE: PROCEDURE IML used (Total process time):

      real time           0.51 seconds

      cpu time            0.51 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   PROC DATASETS NOLIST NOWARN NOPRINT;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DELETE TemporaryDatasetForBCHmacro;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   RUN;

 

NOTE: Deleting WORK.TEMPORARYDATASETFORBCHMACRO (memtype=DATA).

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %PUT _all_

LCA_COVARIATES_3STEP_NO_GROUPS ADJUSTMENT BCH

LCA_COVARIATES_3STEP_NO_GROUPS ASSIGNMENT Modal

LCA_COVARIATES_3STEP_NO_GROUPS AUTOMATICALLY_ADD_INTERCEPT 1

LCA_COVARIATES_3STEP_NO_GROUPS COVARIATES Other nonConfor AI Asian Hispanic genOther White age14to24

covid irflag

LCA_COVARIATES_3STEP_NO_GROUPS ID actor_id

LCA_COVARIATES_3STEP_NO_GROUPS NCLASSES            4

LCA_COVARIATES_3STEP_NO_GROUPS POSTPROBS my_post4

LCA_COVARIATES_3STEP_NO_GROUPS REF_CLASS 1

LCA_COVARIATES_3STEP_NO_GROUPS SAMPLING_WEIGHT

LCA_COVARIATES_3STEP ADJUSTMENT BCH

LCA_COVARIATES_3STEP ASSIGNMENT Modal

LCA_COVARIATES_3STEP AUTOMATICALLY_ADD_INTERCEPT 1

LCA_COVARIATES_3STEP COVARIATES Other nonConfor AI Asian Hispanic genOther White age14to24 covid

irflag

LCA_COVARIATES_3STEP GROUPS

LCA_COVARIATES_3STEP ID actor_id

LCA_COVARIATES_3STEP POSTPROBS my_post4

LCA_COVARIATES_3STEP REF_CLASS 1

LCA_COVARIATES_3STEP SAMPLING_WEIGHT

LCA_COVARIATES_3STEP THERE_ARE_GROUPS 0

AUTOMATIC AFDSID 0

AUTOMATIC AFDSNAME

AUTOMATIC AFLIB

AUTOMATIC AFSTR1

AUTOMATIC AFSTR2

AUTOMATIC FSPBDV

AUTOMATIC SYSADDRBITS 64

AUTOMATIC SYSBUFFR

AUTOMATIC SYSCC 3000

AUTOMATIC SYSCHARWIDTH 1

AUTOMATIC SYSCMD

AUTOMATIC SYSDATASTEPPHASE

AUTOMATIC SYSDATE 03DEC20

AUTOMATIC SYSDATE9 03DEC2020

AUTOMATIC SYSDAY Thursday

AUTOMATIC SYSDEVIC

AUTOMATIC SYSDMG 0

AUTOMATIC SYSDSN WORK    TEMPORARYDATASETFORBCHMACRO

AUTOMATIC SYSENCODING utf-8

AUTOMATIC SYSENDIAN LITTLE

AUTOMATIC SYSENV FORE

AUTOMATIC SYSERR 0

AUTOMATIC SYSERRORTEXT File WORK.WEIGHTED_GLOGIT_SANDWICH_COV.DATA does not exist.

AUTOMATIC SYSFILRC 0

AUTOMATIC SYSHOSTINFOLONG X64_SRV16 WIN 10.0.14393  Server

AUTOMATIC SYSHOSTNAME Aperture

AUTOMATIC SYSINCLUDEFILEDEVICE

AUTOMATIC SYSINCLUDEFILEDIR

AUTOMATIC SYSINCLUDEFILEFILEREF

AUTOMATIC SYSINCLUDEFILENAME

AUTOMATIC SYSINDEX 20

AUTOMATIC SYSINFO 0

AUTOMATIC SYSJOBID 544

AUTOMATIC SYSLAST WORK.TEMPORARYDATASETFORBCHMACRO

AUTOMATIC SYSLCKRC 0

AUTOMATIC SYSLIBRC 0

AUTOMATIC SYSLOGAPPLNAME

AUTOMATIC SYSMACRONAME LCA_COVARIATES_3STEP_NO_GROUPS

AUTOMATIC SYSMAXLONG 2147483647

AUTOMATIC SYSMENV

AUTOMATIC SYSMSG

AUTOMATIC SYSNCPU 4

AUTOMATIC SYSNOBS 16

AUTOMATIC SYSODSESCAPECHAR 03

AUTOMATIC SYSODSGRAPHICS 1

AUTOMATIC SYSODSPATH  SASUSER.TEMPLAT(UPDATE) SASHELP.TMPLMST(READ)

AUTOMATIC SYSPARM

AUTOMATIC SYSPRINTTOLOG

AUTOMATIC SYSPRINTTOLIST

AUTOMATIC SYSPROCESSID 41DCA65620DAD0E54018000000000000

AUTOMATIC SYSPROCESSMODE SAS DMS Session

AUTOMATIC SYSPROCESSNAME DMS Process

AUTOMATIC SYSPROCNAME DATASETS

AUTOMATIC SYSRC 0

AUTOMATIC SYSSCP WIN

AUTOMATIC SYSSCPL X64_SRV16

AUTOMATIC SYSSITE 70080458

AUTOMATIC SYSSIZEOFLONG 4

AUTOMATIC SYSSIZEOFPTR 8

AUTOMATIC SYSSIZEOFUNICODE 2

AUTOMATIC SYSSTARTID

AUTOMATIC SYSSTARTNAME

AUTOMATIC SYSTCPIPHOSTNAME Aperture

AUTOMATIC SYSTIME 22:04

AUTOMATIC SYSTIMEZONE

AUTOMATIC SYSTIMEZONEIDENT

AUTOMATIC SYSTIMEZONEOFFSET -18000

AUTOMATIC SYSUSERID jrunkle

AUTOMATIC SYSVER 9.4

AUTOMATIC SYSVLONG 9.04.01M6P110718

AUTOMATIC SYSVLONG4 9.04.01M6P11072018

AUTOMATIC SYSWARNINGTEXT Data set WORK.SANDWICH_COVARIANCE was not replaced because this step was

stopped.

MLOGIC(CALCULATECLASS_WEIGHTS):  Beginning execution.

MLOGIC(CALCULATECLASS_WEIGHTS):  Parameter POSTPROBSDATASET has value my_post4

MLOGIC(CALCULATECLASS_WEIGHTS):  Parameter SUBJECTID has value actor_id

MLOGIC(CALCULATECLASS_WEIGHTS):  Parameter NCLASSES has value 4

MLOGIC(CALCULATECLASS_WEIGHTS):  Parameter SAMPLING_WEIGHT has value

MLOGIC(CALCULATECLASS_WEIGHTS):  Parameter ASSIGNMENT has value Modal

MLOGIC(CALCULATECLASS_WEIGHTS):  Parameter ADJUSTMENT has value BCH

 

NOTE: PROCEDURE DATASETS used (Total process time):

      real time           0.07 seconds

      cpu time            0.06 seconds

 

 

MPRINT(CALCULATECLASS_WEIGHTS):   PROC IML;

NOTE: IML Ready

MPRINT(CALCULATECLASS_WEIGHTS):   Assignment = LOWCASE(TRIM("Modal"));

MPRINT(CALCULATECLASS_WEIGHTS):   Adjustment = LOWCASE(TRIM("BCH"));

MPRINT(CALCULATECLASS_WEIGHTS):   IF (Assignment^="modal" & Assignment^="proportional") THEN DO;

MPRINT(CALCULATECLASS_WEIGHTS):   PRINT ("Assignment option not recognized:");

MPRINT(CALCULATECLASS_WEIGHTS):   PRINT(Assignment);

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   IF (Adjustment^="bch" & Adjustment^="none") THEN DO;

MPRINT(CALCULATECLASS_WEIGHTS):   PRINT ("Adjustment option not recognized:");

MPRINT(CALCULATECLASS_WEIGHTS):   PRINT(Adjustment);

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   USE my_post4;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop beginning; index variable CLASS; start value is 1; stop

      value is 4; by value is 1.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 2; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 3; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 4; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 5; loop will not iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   READ ALL VAR {actor_id PostLC1 PostLC2 PostLC3 PostLC4 Best};

MPRINT(CALCULATECLASS_WEIGHTS):   CLOSE my_post4;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop beginning; index variable CLASS; start value is 2; stop

      value is 4; by value is 1.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 3; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 4; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 5; loop will not iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   PostLC = PostLC1 || PostLC2 || PostLC3 || PostLC4 ;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop beginning; index variable CLASS; start value is 2; stop

      value is 4; by value is 1.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 3; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 4; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 5; loop will not iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   IsBestLC = (Best=1) || (Best=2) || (Best=3) || (Best=4) ;

MPRINT(CALCULATECLASS_WEIGHTS):   UnadjustedWeights = J(NROW(IsBestLC),4,.);

MPRINT(CALCULATECLASS_WEIGHTS):   IF (Assignment="modal") THEN DO;

MPRINT(CALCULATECLASS_WEIGHTS):   UnadjustedWeights = IsBestLC;

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   ELSE DO;

MPRINT(CALCULATECLASS_WEIGHTS):   UnadjustedWeights = PostLC;

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   IF (LENGTH(LOWCASE(TRIM("_")))>1) THEN DO;

MPRINT(CALCULATECLASS_WEIGHTS):   DO class = 1 TO 4;

MPRINT(CALCULATECLASS_WEIGHTS):   UnadjustedWeights[,class] = ( + 0)#UnadjustedWeights[,class];

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   ELSE DO;

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   IF (Adjustment="bch") THEN DO;

MPRINT(CALCULATECLASS_WEIGHTS):   D = J(4,4,.);

MPRINT(CALCULATECLASS_WEIGHTS):   DO t = 1 TO 4;

MPRINT(CALCULATECLASS_WEIGHTS):   DO s = 1 TO 4;

MPRINT(CALCULATECLASS_WEIGHTS):   D[t,s] = ((PostLC[,t] # UnadjustedWeights[,s])[+]) / (PostLC[+,t]);

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   Class_Weights = UnadjustedWeights * INV(D);

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MPRINT(CALCULATECLASS_WEIGHTS):   ELSE DO;

MPRINT(CALCULATECLASS_WEIGHTS):   Class_Weights = UnadjustedWeights;

MPRINT(CALCULATECLASS_WEIGHTS):   END;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop beginning; index variable CLASS; start value is 1; stop

      value is 4; by value is 1.

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeightLC1 = Class_Weights[,1];

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 2; loop will iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeightLC2 = Class_Weights[,2];

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 3; loop will iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeightLC3 = Class_Weights[,3];

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 4; loop will iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeightLC4 = Class_Weights[,4];

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 5; loop will not iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop beginning; index variable CLASS; start value is 1; stop

      value is 4; by value is 1.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 2; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 3; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 4; loop will iterate again.

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 5; loop will not iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   CREATE Class_Weights VAR {actor_id ClassWeightLC1 ClassWeightLC2

ClassWeightLC3 ClassWeightLC4};

MPRINT(CALCULATECLASS_WEIGHTS):   APPEND ;

MPRINT(CALCULATECLASS_WEIGHTS):   CLOSE Class_Weights;

NOTE: The data set WORK.CLASS_WEIGHTS has 157274 observations and 5 variables.

MPRINT(CALCULATECLASS_WEIGHTS):   QUIT;

NOTE: Exiting IML.

NOTE: PROCEDURE IML used (Total process time):

      real time           0.31 seconds

      cpu time            0.28 seconds

 

 

MPRINT(CALCULATECLASS_WEIGHTS):   DATA Class_Weights_Long;

MPRINT(CALCULATECLASS_WEIGHTS):   SET Class_Weights;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop beginning; index variable CLASS; start value is 1; stop

      value is 4; by value is 1.

MPRINT(CALCULATECLASS_WEIGHTS):   Class = 1;

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeight = ClassWeightLC1;

MPRINT(CALCULATECLASS_WEIGHTS):   OUTPUT;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 2; loop will iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   Class = 2;

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeight = ClassWeightLC2;

MPRINT(CALCULATECLASS_WEIGHTS):   OUTPUT;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 3; loop will iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   Class = 3;

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeight = ClassWeightLC3;

MPRINT(CALCULATECLASS_WEIGHTS):   OUTPUT;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 4; loop will iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   Class = 4;

MPRINT(CALCULATECLASS_WEIGHTS):   ClassWeight = ClassWeightLC4;

MPRINT(CALCULATECLASS_WEIGHTS):   OUTPUT;

MLOGIC(CALCULATECLASS_WEIGHTS):  %DO loop index variable CLASS is now 5; loop will not iterate again.

MPRINT(CALCULATECLASS_WEIGHTS):   KEEP actor_id Class ClassWeight;

MPRINT(CALCULATECLASS_WEIGHTS):   RUN;

 

NOTE: There were 157274 observations read from the data set WORK.CLASS_WEIGHTS.

NOTE: The data set WORK.CLASS_WEIGHTS_LONG has 629096 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.11 seconds

      cpu time            0.04 seconds

 

 

MLOGIC(CALCULATECLASS_WEIGHTS):  Ending execution.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):  ;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DATA ForAnalysis;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   MERGE my_post4 Class_Weights;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   BY actor_id;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   RUN;

 

NOTE: There were 157274 observations read from the data set WORK.MY_POST4.

NOTE: There were 157274 observations read from the data set WORK.CLASS_WEIGHTS.

NOTE: The data set WORK.FORANALYSIS has 157274 observations and 20 variables.

NOTE: DATA statement used (Total process time):

      real time           0.16 seconds

      cpu time            0.12 seconds

 

 

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %IF condition %EVAL(&automatically_add_intercept>0) is TRUE

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DATA ForAnalysis;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   SET ForAnalysis;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   _Intercept_ = 1;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   RUN;

 

NOTE: There were 157274 observations read from the data set WORK.FORANALYSIS.

NOTE: The data set WORK.FORANALYSIS has 157274 observations and 21 variables.

NOTE: DATA statement used (Total process time):

      real time           0.14 seconds

      cpu time            0.11 seconds

 

 

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %LET (variable name is COVARIATES)

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DATA ForAnalysisLong;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   SET ForAnalysis;

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop beginning; index variable CLASS; start value is 1;

      stop value is 4; by value is 1.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   LC = 1;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   ClassWeight = ClassWeightLC1;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   OUTPUT;

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 2; loop will iterate

      again.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   LC = 2;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   ClassWeight = ClassWeightLC2;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   OUTPUT;

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 3; loop will iterate

      again.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   LC = 3;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   ClassWeight = ClassWeightLC3;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   OUTPUT;

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 4; loop will iterate

      again.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   LC = 4;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   ClassWeight = ClassWeightLC4;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   OUTPUT;

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 5; loop will not

      iterate again.

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop beginning; index variable CLASS; start value is 1;

      stop value is 4; by value is 1.

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 2; loop will iterate

      again.

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 3; loop will iterate

      again.

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 4; loop will iterate

      again.

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  %DO loop index variable CLASS is now 5; loop will not

      iterate again.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DROP ClassWeightLC1 ClassWeightLC2 ClassWeightLC3

ClassWeightLC4 ;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   RUN;

 

NOTE: There were 157274 observations read from the data set WORK.FORANALYSIS.

NOTE: The data set WORK.FORANALYSISLONG has 629096 observations and 19 variables.

NOTE: DATA statement used (Total process time):

      real time           0.37 seconds

      cpu time            0.28 seconds

 

 

MLOGIC(DOWEIGHTEDGLOGIT):  Beginning execution.

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter INPUTDATASET has value ForAnalysisLong

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter OUTCOMECLASS has value LC

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter REF_CLASS has value 1

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter WEIGHT has value ClassWeight

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter COVARIATES has value _Intercept_ Other nonConfor AI Asian

      Hispanic genOther White age14to24 covid irflag

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter SUBJECTID has value actor_id

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter OBSERVATIONID has value LC

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter REGULARIZATIONCONSTANTEXP has value 0

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter REGULARIZATIONCONSTANTFORCOV has value 0

MLOGIC(DOWEIGHTEDGLOGIT):  Parameter REGULARIZATIONCONSTANTFORSE has value 0

MPRINT(DOWEIGHTEDGLOGIT):   PROC IML;

NOTE: IML Ready

MPRINT(DOWEIGHTEDGLOGIT):   USE ForAnalysisLong;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {LC} INTO Y;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {ClassWeight} INTO W;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {_Intercept_ Other nonConfor AI Asian Hispanic genOther

White age14to24 covid irflag} INTO XMatrix;

ERROR: OTHER is not in the scope of variables for the data set.

 

statement : READ at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {actor_id} INTO id;

MPRINT(DOWEIGHTEDGLOGIT):   CLOSE ForAnalysisLong;

MPRINT(DOWEIGHTEDGLOGIT):   numCovariates = NCOL(XMatrix);

MPRINT(DOWEIGHTEDGLOGIT):   numClasses = Y[<>];

MPRINT(DOWEIGHTEDGLOGIT):   CALL SYMPUT("numCovariates",(CHAR(numCovariates)));

MPRINT(DOWEIGHTEDGLOGIT):   CALL SYMPUT("numClasses",(CHAR(numClasses)));

MPRINT(DOWEIGHTEDGLOGIT):   DataForNlmixedAsMatrix = id || W || Y || XMatrix;

MPRINT(DOWEIGHTEDGLOGIT):   VariableNames = "id" || "W" || "Y" || ("X1":"X           0");

MPRINT(DOWEIGHTEDGLOGIT):   CREATE DataForNlmixed FROM DataForNlmixedAsMatrix [COLNAME=VariableNames];

NOTE: The colname matrix size does not match the number of columns in the FROM matrix.

MPRINT(DOWEIGHTEDGLOGIT):   APPEND FROM DataForNlmixedAsMatrix ;

MPRINT(DOWEIGHTEDGLOGIT):   CLOSE DataForNlmixed;

NOTE: The data set WORK.DATAFORNLMIXED has 629096 observations and 3 variables.

MPRINT(DOWEIGHTEDGLOGIT):   QUIT;

NOTE: Exiting IML.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.62 seconds

      cpu time            0.57 seconds

 

MPRINT(DOWEIGHTEDGLOGIT):   ODS EXCLUDE ALL;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

MPRINT(DOWEIGHTEDGLOGIT):   ODS NORESULTS;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

MPRINT(DOWEIGHTEDGLOGIT):   PROC NLMIXED DATA=DataForNlmixed COV START HESS METHOD=GAUSS TECH=NRRIDG

MAXITER=500 MAXFUNC=1000;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop beginning; index variable K; start value is 1; stop value is 0;

      by value is 1.  Loop will not be executed.

MPRINT(DOWEIGHTEDGLOGIT):   PARMS ;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop beginning; index variable C; start value is 1; stop value is 4;

      by value is 1.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   eta1 = 0;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 2; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&numCovariates>1) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   eta2 = b12*X1 ;

MPRINT(DOWEIGHTEDGLOGIT):   expEta2 = EXP(eta2 + 0);

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 3; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&numCovariates>1) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   eta3 = b13*X1 ;

MPRINT(DOWEIGHTEDGLOGIT):   expEta3 = EXP(eta3 + 0);

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 4; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&numCovariates>1) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   eta4 = b14*X1 ;

MPRINT(DOWEIGHTEDGLOGIT):   expEta4 = EXP(eta4 + 0);

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 5; loop will not iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop beginning; index variable C; start value is 1; stop value is 4;

      by value is 1.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is FALSE

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 2; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 3; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 4; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 5; loop will not iterate again.

MPRINT(DOWEIGHTEDGLOGIT):   denominator = 1 + expEta2 + expEta3 + expEta4 ;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop beginning; index variable C; start value is 1; stop value is 4;

      by value is 1.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   IF Y=1 THEN likelihood = 1/denominator;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 2; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MPRINT(DOWEIGHTEDGLOGIT):   IF Y=2 THEN likelihood = expEta2/denominator;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 3; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MPRINT(DOWEIGHTEDGLOGIT):   IF Y=3 THEN likelihood = expEta3/denominator;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 4; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MPRINT(DOWEIGHTEDGLOGIT):   IF Y=4 THEN likelihood = expEta4/denominator;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 5; loop will not iterate again.

MPRINT(DOWEIGHTEDGLOGIT):   SumSquaredBetas = 0;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop beginning; index variable C; start value is 1; stop value is 4;

      by value is 1.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is FALSE

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 2; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&numCovariates>1) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   SumSquaredBetas = SumSquaredBetas + (b12)**2;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 3; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&numCovariates>1) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   SumSquaredBetas = SumSquaredBetas + (b13)**2;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 4; loop will iterate again.

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&c ^= &Ref_Class) is TRUE

MLOGIC(DOWEIGHTEDGLOGIT):  %IF condition %EVAL(&numCovariates>1) is FALSE

MPRINT(DOWEIGHTEDGLOGIT):   SumSquaredBetas = SumSquaredBetas + (b14)**2;

MLOGIC(DOWEIGHTEDGLOGIT):  %DO loop index variable C is now 5; loop will not iterate again.

MPRINT(DOWEIGHTEDGLOGIT):   loglikelihood = W *LOG(likelihood) ;

MPRINT(DOWEIGHTEDGLOGIT):   MODEL Y ~ GENERAL(loglikelihood);

MPRINT(DOWEIGHTEDGLOGIT):   if Y = . then _ll = .;

MPRINT(DOWEIGHTEDGLOGIT):   else if _est0 = . then _ll = .;

MPRINT(DOWEIGHTEDGLOGIT):   else do;

MPRINT(DOWEIGHTEDGLOGIT):   _ll = _est0;

MPRINT(DOWEIGHTEDGLOGIT):   end;

MPRINT(DOWEIGHTEDGLOGIT):   ODS OUTPUT PARAMETERESTIMATES=Weighted_GLogit_Coef

CONVERGENCESTATUS=Weighted_Glogit_Convergence;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

NOTE: The parameters b12, X1, b13, b14 are assigned the default starting value of 1.0, because they

      are not assigned initial values with the PARMS statement.

NOTE: Convergence criterion (GCONV=1E-8) satisfied.

NOTE: At least one element of the gradient is greater than 1e-3.

NOTE: Moore-Penrose inverse is used in covariance matrix.

WARNING: The final Hessian matrix is full rank but has at least one negative eigenvalue. Second-order

         optimality condition violated.

NOTE: The data set WORK.WEIGHTED_GLOGIT_CONVERGENCE has 1 observations and 2 variables.

NOTE: The data set WORK.WEIGHTED_GLOGIT_COEF has 4 observations and 10 variables.

NOTE: PROCEDURE NLMIXED used (Total process time):

      real time           18.07 seconds

      cpu time            17.96 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   PROC PRINT DATA=Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.WEIGHTED_GLOGIT_COEF.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   DATA Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   SET Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   Row = _N_;

MPRINT(DOWEIGHTEDGLOGIT):   Covariate = INT((Row-1)/( 4-1))+1;

MPRINT(DOWEIGHTEDGLOGIT):   Class = Row-(Covariate-1)*( 4-1);

MPRINT(DOWEIGHTEDGLOGIT):   IF (Class=>1) THEN Class = Class + 1;

MPRINT(DOWEIGHTEDGLOGIT):   DROP Row;

MPRINT(DOWEIGHTEDGLOGIT):   Std_Err = .;

MPRINT(DOWEIGHTEDGLOGIT):   KEEP Covariate Class Estimate Std_Err;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.WEIGHTED_GLOGIT_COEF.

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

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.03 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   PROC PRINT DATA=Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.WEIGHTED_GLOGIT_COEF.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   PROC SORT DATA=Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   BY Class Covariate;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.WEIGHTED_GLOGIT_COEF.

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

NOTE: PROCEDURE SORT used (Total process time):

      real time           0.02 seconds

      cpu time            0.03 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   PROC PRINT DATA=Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.WEIGHTED_GLOGIT_COEF.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   DATA TempDatasetForMacro;

MPRINT(DOWEIGHTEDGLOGIT):   SET ForAnalysisLong;

MPRINT(DOWEIGHTEDGLOGIT):   BY actor_id;

MPRINT(DOWEIGHTEDGLOGIT):   RETAIN BCHMacroIntID 0;

MPRINT(DOWEIGHTEDGLOGIT):   IF first.actor_id THEN BCHMacroIntID = BCHMacroIntID + 1;

MPRINT(DOWEIGHTEDGLOGIT):   OUTPUT;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

 

NOTE: There were 629096 observations read from the data set WORK.FORANALYSISLONG.

NOTE: The data set WORK.TEMPDATASETFORMACRO has 629096 observations and 20 variables.

NOTE: DATA statement used (Total process time):

      real time           0.49 seconds

      cpu time            0.34 seconds

 

 

MPRINT(DOWEIGHTEDGLOGIT):   PROC IML;

NOTE: IML Ready

MPRINT(DOWEIGHTEDGLOGIT):   USE Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {Covariate Class Estimate};

MPRINT(DOWEIGHTEDGLOGIT):   CLOSE Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   USE TempDatasetForMacro;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {LC} INTO Y;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {ClassWeight} INTO W;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {_Intercept_ Other nonConfor AI Asian Hispanic genOther

White age14to24 covid irflag} INTO XMatrix;

ERROR: OTHER is not in the scope of variables for the data set.

 

statement : READ at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {BCHMacroIntID} INTO ClusterId;

MPRINT(DOWEIGHTEDGLOGIT):   READ ALL VAR {LC} INTO MemberID;

MPRINT(DOWEIGHTEDGLOGIT):   CLOSE TempDatasetForMacro;

MPRINT(DOWEIGHTEDGLOGIT):   p = NCOL(XMatrix);

MPRINT(DOWEIGHTEDGLOGIT):   ntotal = NROW(Y);

MPRINT(DOWEIGHTEDGLOGIT):   nsub = ClusterID[<>];

MPRINT(DOWEIGHTEDGLOGIT):   PRINT ClusterID;

MPRINT(DOWEIGHTEDGLOGIT):   PRINT ntotal nsub;

MPRINT(DOWEIGHTEDGLOGIT):   m = ntotal / nsub;

MPRINT(DOWEIGHTEDGLOGIT):   n = ntotal / m;

MPRINT(DOWEIGHTEDGLOGIT):   nc = Y[<>];

MPRINT(DOWEIGHTEDGLOGIT):   YAsMatrix = J(n*m,nc,0);

MPRINT(DOWEIGHTEDGLOGIT):   DO c = 1 TO nc;

MPRINT(DOWEIGHTEDGLOGIT):   IF SUM(Y=c)>0 THEN DO;

MPRINT(DOWEIGHTEDGLOGIT):   whichrows = LOC(Y=c)`;

MPRINT(DOWEIGHTEDGLOGIT):   YAsMatrix[whichrows,c] = 1;

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   CoefAsVector = Estimate;

MPRINT(DOWEIGHTEDGLOGIT):   ModelInformationMatrix = J((nc-1)*p,(nc-1)*p,0);

ERROR: (execution) Invalid operand to operation.

 

operation : J at line 1655 column 1

operands  : _TEM1002, _TEM1004, *LIT1013

 

_TEM1002      1 row       1 col     (numeric)

 

         0

 

_TEM1004      1 row       1 col     (numeric)

 

         0

 

*LIT1013      1 row       1 col     (numeric)

 

         0

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   TotalScoreVector = J((nc-1)*p,1,0);

ERROR: (execution) Invalid operand to operation.

 

operation : J at line 1655 column 1

operands  : _TEM1002, *LIT1015, *LIT1016

 

_TEM1002      1 row       1 col     (numeric)

 

         0

 

*LIT1015      1 row       1 col     (numeric)

 

         1

 

*LIT1016      1 row       1 col     (numeric)

 

         0

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   EmpiricalCovOfScore = J(p*(nc-1),p*(nc-1),0);

ERROR: (execution) Invalid operand to operation.

 

operation : J at line 1655 column 1

operands  : _TEM1002, _TEM1004, *LIT1019

 

_TEM1002      1 row       1 col     (numeric)

 

         0

 

_TEM1004      1 row       1 col     (numeric)

 

         0

 

*LIT1019      1 row       1 col     (numeric)

 

         0

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   CoefAsMatrix = SHAPE(CoefAsVector,nc-1)`;

ERROR: (execution) Invalid operand to operation.

 

operation : SHAPE at line 1655 column 1

operands  : CoefAsVector, _TEM1001

 

CoefAsVector      4 rows      1 col     (numeric)

 

0.7460985

0.5490168

0.8688431

1.6429111

 

_TEM1001      1 row       1 col     (numeric)

 

         3

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   ref_class = 1;

MPRINT(DOWEIGHTEDGLOGIT):   IF (ref_class = 1) THEN DO;

MPRINT(DOWEIGHTEDGLOGIT):   Nonref_classes = 2:nc;

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   IF (ref_class = nc) THEN DO;

MPRINT(DOWEIGHTEDGLOGIT):   Nonref_classes = 1:(nc-1);

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   IF ((ref_class >1) & (ref_class < nc)) THEN DO;

MPRINT(DOWEIGHTEDGLOGIT):   Nonref_classes = (1:(ref_class-1)) || ((ref_class+1):nc);

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   DO i = 1 TO n;

MPRINT(DOWEIGHTEDGLOGIT):   ScoreVector = J((nc-1)*p,1,0);

MPRINT(DOWEIGHTEDGLOGIT):   DO j = 1 TO m;

MPRINT(DOWEIGHTEDGLOGIT):   wij = w[LOC(ClusterID=i & MemberID=j)];

MPRINT(DOWEIGHTEDGLOGIT):   * Assumes there is only one such entry. ;

MPRINT(DOWEIGHTEDGLOGIT):   yij = YasMatrix[LOC(ClusterID=i & MemberID=j),]`;

MPRINT(DOWEIGHTEDGLOGIT):   xij = XMatrix[LOC(ClusterID=i & MemberID=j),];

MPRINT(DOWEIGHTEDGLOGIT):   eta = J(nc,1,0);

MPRINT(DOWEIGHTEDGLOGIT):   eta[Nonref_classes] = xij*CoefAsMatrix;

MPRINT(DOWEIGHTEDGLOGIT):   eta = (eta <> -20) >< +20;

MPRINT(DOWEIGHTEDGLOGIT):   eta = eta + 0;

MPRINT(DOWEIGHTEDGLOGIT):   expEta = EXP(eta);

MPRINT(DOWEIGHTEDGLOGIT):   piij = expEta / expEta[+];

MPRINT(DOWEIGHTEDGLOGIT):   Mij = DIAG(piij[Nonref_classes]) -

piij[Nonref_classes]*piij[Nonref_classes]`;

MPRINT(DOWEIGHTEDGLOGIT):   BigXij = (I(nc-1) @ xij)`;

MPRINT(DOWEIGHTEDGLOGIT):   ScoreVector = ScoreVector +

wij*BigXij*(yij[Nonref_classes]-piij[Nonref_classes]);

MPRINT(DOWEIGHTEDGLOGIT):   ModelInformationMatrix = ModelInformationMatrix + wij*BigXij*Mij*BigXij`;

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   TotalScoreVector = TotalScoreVector + ScoreVector;

MPRINT(DOWEIGHTEDGLOGIT):   EmpiricalCovOfScore = EmpiricalCovOfScore + ScoreVector*ScoreVector`;

MPRINT(DOWEIGHTEDGLOGIT):   END;

ERROR: (execution) Invalid operand to operation.

 

operation : J at line 1655 column 1

operands  : _TEM1002, *LIT1032, *LIT1033

 

_TEM1002      1 row       1 col     (numeric)

 

         0

 

*LIT1032      1 row       1 col     (numeric)

 

         1

 

*LIT1033      1 row       1 col     (numeric)

 

         0

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   CoefAsVectorOld = CoefAsVector;

MPRINT(DOWEIGHTEDGLOGIT):   lambda = 0*(VECDIAG(ModelInformationMatrix))[+];

ERROR: (execution) Matrix has not been set to a value.

 

operation : VECDIAG at line 1655 column 1

operands  : ModelInformationMatrix

 

ModelInformationMatrix      0 row       0 col     (type ?, size 0)

 

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   NaiveCovCoef =

INV(ModelInformationMatrix+lambda*I(NROW(ModelInformationMatrix)));

ERROR: (execution) Invalid operand to operation.

 

operation : I at line 1655 column 1

operands  : _TEM1001

 

_TEM1001      1 row       1 col     (numeric)

 

         0

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   CoefAsVector = CoefAsVector + NaiveCovCoef*TotalScoreVector;

ERROR: (execution) Matrix has not been set to a value.

 

operation : * at line 1655 column 1

operands  : NaiveCovCoef, TotalScoreVector

 

NaiveCovCoef      0 row       0 col     (type ?, size 0)

 

 

TotalScoreVector      0 row       0 col     (type ?, size 0)

 

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   MaxAbsDev = (ABS(CoefAsVector - CoefAsVectorOld))[<>];

MPRINT(DOWEIGHTEDGLOGIT):   CorrectionFactor = (n/(n-1))*((n*m-1)/(n*m-(nc-1)*p));

MPRINT(DOWEIGHTEDGLOGIT):   * In SAS PROC SURVEYLOGISTIC, the option VADJUST=NONE uses n/(n-1). * The

option VADJUST=DF uses (n/(n-1))*((n*m-1)/(n*m-(nc-1)*p)). ;

MPRINT(DOWEIGHTEDGLOGIT):   SandwichCov = NaiveCovCoef` * (CorrectionFactor*EmpiricalCovOfScore) *

NaiveCovCoef;

ERROR: (execution) Matrix has not been set to a value.

 

operation : ` at line 1655 column 1

operands  : NaiveCovCoef

 

NaiveCovCoef      0 row       0 col     (type ?, size 0)

 

 

statement : ASSIGN at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   IF (VECDIAG(SandwichCov)[><]>0) THEN DO;

MPRINT(DOWEIGHTEDGLOGIT):   Std_Err = SQRT(VECDIAG(SandwichCov));

MPRINT(DOWEIGHTEDGLOGIT):   END;

MPRINT(DOWEIGHTEDGLOGIT):   ELSE DO;

MPRINT(DOWEIGHTEDGLOGIT):   Std_Err = J(NROW(SandwichCov),1,.);

MPRINT(DOWEIGHTEDGLOGIT):   END;

ERROR: (execution) Matrix has not been set to a value.

 

operation : VECDIAG at line 1655 column 1

operands  : SandwichCov

 

SandwichCov      0 row       0 col     (type ?, size 0)

 

 

statement : IF at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   EDIT Weighted_GLogit_Coef;

MPRINT(DOWEIGHTEDGLOGIT):   REPLACE ALL VAR {Std_Err };

WARNING: All data set variables are unvalued. No REPLACE done.

 

statement : REPLACE at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   CLOSE Weighted_GLogit_Coef;

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

MPRINT(DOWEIGHTEDGLOGIT):   CREATE Weighted_GLogit_Sandwich_Cov FROM SandwichCov;

ERROR: Matrix SandwichCov has not been set to a value.

 

statement : CREATE at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   APPEND FROM SandwichCov;

ERROR: No data set is currently open for output.

 

statement : APPEND at line 1655 column 1

MPRINT(DOWEIGHTEDGLOGIT):   CLOSE Weighted_GLogit_Sandwich_Cov;

NOTE: Cannot close WORK.WEIGHTED_GLOGIT_SANDWICH_COV; it is not open.

MPRINT(DOWEIGHTEDGLOGIT):   QUIT;

NOTE: Exiting IML.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.73 seconds

      cpu time            0.67 seconds

 

MPRINT(DOWEIGHTEDGLOGIT):   ODS EXCLUDE NONE;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

MPRINT(DOWEIGHTEDGLOGIT):   ODS RESULTS;

MPRINT(DOWEIGHTEDGLOGIT):   RUN;

MLOGIC(DOWEIGHTEDGLOGIT):  Ending execution.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):  ;

 

 

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   PROC IML;

NOTE: IML Ready

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   USE Weighted_GLogit_Coef;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   READ ALL;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   CLOSE Weighted_GLogit_Coef;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   CovariateIndex = Covariate;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   NamesString = "_Intercept_ Other nonConfor AI Asian

Hispanic genOther White age14to24 covid irflag";

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   NumCov = 1 + COUNT(NamesString," ");

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Name = J(NROW(CovariateIndex),1,"

       ");

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   DO i = 1 TO NumCov;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Name[LOC(CovariateIndex=i)] = SCANQ(NamesString,i);

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   END;

ERROR: (execution) Matrix has not been set to a value.

 

operation : [ at line 1655 column 1

operands  : Name, _TEM1002, _TEM1003

 

Name      4 rows      1 col     (character, size 34)

 

_Intercept_

Other

_Intercept_

_Intercept_

 

_TEM1002      0 row       0 col     (type ?, size 0)

 

 

_TEM1003      1 row       1 col     (character, size 9)

 

nonConfor

 

statement : ASSIGN at line 1655 column 1

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Beta = Estimate;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Exp_Beta = EXP(Beta);

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Upper_CI_Beta = Beta + 1.96 * Std_Err;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Lower_CI_Beta = Beta - 1.96 * Std_Err;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Upper_CI_Exp_Beta = EXP(Upper_CI_Beta);

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Lower_CI_Exp_Beta = EXP(Lower_CI_Beta);

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   Z = Estimate / Std_Err;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   p = 1 - PROBNORM(ABS(Z));

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   CREATE Covariates_Macro_This_Group VAR {Name Class Beta

Std_Err Z p Lower_CI_Beta Upper_CI_Beta Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta};

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   APPEND;

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   CLOSE Covariates_Macro_This_Group;

NOTE: The data set WORK.COVARIATES_MACRO_THIS_GROUP has 4 observations and 11 variables.

MPRINT(LCA_COVARIATES_3STEP_NO_GROUPS):   QUIT;

NOTE: Exiting IML.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.03 seconds

      cpu time            0.01 seconds

 

MLOGIC(LCA_COVARIATES_3STEP_NO_GROUPS):  Ending execution.

MPRINT(LCA_COVARIATES_3STEP):  ;

 

 

MPRINT(LCA_COVARIATES_3STEP):   DATA Covariates_Macro_Answers;

MPRINT(LCA_COVARIATES_3STEP):   SET Covariates_Macro_This_Group;

MPRINT(LCA_COVARIATES_3STEP):   RUN;

NOTE: There were 4 observations read from the data set WORK.COVARIATES_MACRO_THIS_GROUP.

NOTE: The data set WORK.COVARIATES_MACRO_ANSWERS has 4 observations and 11 variables.

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.00 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP):   DATA Sandwich_Covariance;

MPRINT(LCA_COVARIATES_3STEP):   SET Weighted_GLogit_Sandwich_Cov;

ERROR: File WORK.WEIGHTED_GLOGIT_SANDWICH_COV.DATA does not exist.

MPRINT(LCA_COVARIATES_3STEP):   RUN;

 

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

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

         were 0 observations and 0 variables.

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

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

 

 

 

MPRINT(LCA_COVARIATES_3STEP):   DATA Covariates_Macro_Convergence;

MPRINT(LCA_COVARIATES_3STEP):   SET Weighted_Glogit_Convergence;

MPRINT(LCA_COVARIATES_3STEP):   RUN;

 

NOTE: There were 1 observations read from the data set WORK.WEIGHTED_GLOGIT_CONVERGENCE.

NOTE: The data set WORK.COVARIATES_MACRO_CONVERGENCE has 1 observations and 2 variables.

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.00 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP):   DATA Covariates_Macro_Answers;

MPRINT(LCA_COVARIATES_3STEP):   SET Covariates_Macro_Answers;

MPRINT(LCA_COVARIATES_3STEP):   WHERE Class IS NOT MISSING;

MPRINT(LCA_COVARIATES_3STEP):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.COVARIATES_MACRO_ANSWERS.

      WHERE Class is not null;

NOTE: The data set WORK.COVARIATES_MACRO_ANSWERS has 4 observations and 11 variables.

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.03 seconds

 

 

MLOGIC(LCA_COVARIATES_3STEP):  %IF condition %EVAL(&there_are_groups=1) is FALSE

MPRINT(LCA_COVARIATES_3STEP):   TITLE "Beta Estimates from LCA_Covariates_3Step Macro";

MPRINT(LCA_COVARIATES_3STEP):   PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

MPRINT(LCA_COVARIATES_3STEP):   VAR Class Name Beta Std_Err Z P;

MPRINT(LCA_COVARIATES_3STEP):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.COVARIATES_MACRO_ANSWERS.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.02 seconds

      cpu time            0.01 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP):   TITLE "Approximate 95% Confidence Intervals for Beta Coefficients";

MPRINT(LCA_COVARIATES_3STEP):   PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

MPRINT(LCA_COVARIATES_3STEP):   VAR Class Name Beta Lower_CI_Beta Upper_CI_Beta;

MPRINT(LCA_COVARIATES_3STEP):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.COVARIATES_MACRO_ANSWERS.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP):   TITLE "Exponentiated Betas (Odds and Odds Ratios) and Approximate 95%

Confidence Intervals";

MPRINT(LCA_COVARIATES_3STEP):   PROC PRINT DATA=Covariates_Macro_Answers NOOBS;

MPRINT(LCA_COVARIATES_3STEP):   VAR Class Name Exp_Beta Lower_CI_Exp_Beta Upper_CI_Exp_Beta;

MPRINT(LCA_COVARIATES_3STEP):   RUN;

 

NOTE: There were 4 observations read from the data set WORK.COVARIATES_MACRO_ANSWERS.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.01 seconds

      cpu time            0.03 seconds

 

 

MPRINT(LCA_COVARIATES_3STEP):   TITLE;

MPRINT(LCA_COVARIATES_3STEP):   PROC DATASETS NOLIST NODETAILS NOWARN;

MPRINT(LCA_COVARIATES_3STEP):   DELETE BCHTemp1 Covariates_Macro_This_Group DataForNlmixed

ForAnalysis ForAnalysisLong TempDatasetForMacro Weighted_GLogit_Coef Weighted_GLogit_Sandwich_Cov

Weighted_Glogit_Convergence ;

MPRINT(LCA_COVARIATES_3STEP):   QUIT;

 

NOTE: Deleting WORK.BCHTEMP1 (memtype=DATA).

NOTE: Deleting WORK.COVARIATES_MACRO_THIS_GROUP (memtype=DATA).

NOTE: Deleting WORK.DATAFORNLMIXED (memtype=DATA).

NOTE: Deleting WORK.FORANALYSIS (memtype=DATA).

NOTE: Deleting WORK.FORANALYSISLONG (memtype=DATA).

NOTE: Deleting WORK.TEMPDATASETFORMACRO (memtype=DATA).

NOTE: Deleting WORK.WEIGHTED_GLOGIT_COEF (memtype=DATA).

NOTE: Deleting WORK.WEIGHTED_GLOGIT_CONVERGENCE (memtype=DATA).

NOTE: PROCEDURE DATASETS used (Total process time):

      real time           0.05 seconds

      cpu time            0.04 seconds

 

 

MLOGIC(LCA_COVARIATES_3STEP):  Ending execution.

1658  *Covariates = Male Other nonConfor AI Asian Hispanic Other White GenOther age14to24 covid irflag

1659   **code calling the 2nd macro w

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 3299 views
  • 0 likes
  • 5 in conversation