Programming the statistical procedures from SAS

proc stdize errors

Accepted Solution Solved
Reply
Super Contributor
Posts: 268
Accepted Solution

proc stdize errors

Hello,

I am using Proc STDIZE for a very mundane task of identifying all numeric variables and converting their missing values to 0. However it is giving an error when there is lack of data.

The original code is here -

%MACRO _CONVERT_MV_TO_ZERO(DATASET);

PROC STDIZE DATA=&DATASET OUT=&DATASET REPONLY MISSING=0;

VAR _NUMERIC_;

RUN;

%MEND _CONVERT_MV_TO_ZERO;

And the log file is here -

SYMBOLGEN:  Macro variable DATASET resolves to SEG_TOT_COMP_PGM_TR
SYMBOLGEN:  Macro variable DATASET resolves to SEG_TOT_COMP_PGM_TR
MPRINT(_CONVERT_MV_TO_ZERO):   PROC STDIZE DATA=SEG_TOT_COMP_PGM_TR OUT=SEG_TOT_COMP_PGM_TR REPONLY MISSING=0;
MPRINT(_CONVERT_MV_TO_ZERO):   VAR _NUMERIC_;
WARNING: No numeric variables found in data set WORK.SEG_TOT_COMP_PGM_TR.
MPRINT(_CONVERT_MV_TO_ZERO):   RUN;

ERROR: No variables to analyze.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements. This may cause NOTE: No observations in data set.
WARNING: The data set WORK.SEG_TOT_COMP_PGM_TR may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.SEG_TOT_COMP_PGM_TR was not replaced because this step was stopped.
NOTE: PROCEDURE STDIZE used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      Memory                            25k
      Page Faults                       4
      Page Reclaims                     22
      Page Swaps                        0
      Voluntary Context Switches        0
      Involuntary Context Switches      1
      Block Input Operations            0
      Block Output Operations           0
     

Is there an option to ignore or bypass the 'No variables to analyze' error?

Thanks,

saspert


Accepted Solutions
Solution
‎08-29-2011 10:57 AM
Esteemed Advisor
Posts: 7,074

proc stdize errors

Couldn't you just change your macro so that it first checks to see if there are any numeric fields?  e.g.:

%MACRO _CONVERT_MV_TO_ZERO(DATASET);

  proc sql noprint;

    select count(*) into :nums

      from dictionary.columns

         where libname="WORK"

            and memname=upcase("&DATASET."

            and type="num"

     ;

  quit;

  %if &nums. gt 0 %then %do;

    PROC STDIZE DATA=&DATASET OUT=&DATASET REPONLY MISSING=0;

     VAR _NUMERIC_;

    RUN;

  %end;

%MEND _CONVERT_MV_TO_ZERO;

View solution in original post


All Replies
Solution
‎08-29-2011 10:57 AM
Esteemed Advisor
Posts: 7,074

proc stdize errors

Couldn't you just change your macro so that it first checks to see if there are any numeric fields?  e.g.:

%MACRO _CONVERT_MV_TO_ZERO(DATASET);

  proc sql noprint;

    select count(*) into :nums

      from dictionary.columns

         where libname="WORK"

            and memname=upcase("&DATASET."

            and type="num"

     ;

  quit;

  %if &nums. gt 0 %then %do;

    PROC STDIZE DATA=&DATASET OUT=&DATASET REPONLY MISSING=0;

     VAR _NUMERIC_;

    RUN;

  %end;

%MEND _CONVERT_MV_TO_ZERO;

Super Contributor
Posts: 268

proc stdize errors

Thanks Art. I was looking for a hint on those lines. But do you know if there is a better way to change the missing values to zero itself. I mean if I can change the way the macro _convert_mv_to_zero works - instead of using PROC STDIZE.


The reason I am asking it because I am not 100% familiar with that procedure and I do get several warnings like these too -

WARNING: The scale estimator for variable SEG_BIO_SCREEN0 is less than or equal to 0. SEG_BIO_SCREEN0 will not be standardized.

WARNING: The scale estimator for variable SEG_BIO_SCREEN1 is less than or equal to 0. SEG_BIO_SCREEN1 will not be standardized.

WARNING: A missing value is assigned to the scale estimator for variable SEG_BIO_SCREEN0 because its scale estimator is less than

or equal to 0 before fuzzing.

WARNING: A missing value is assigned to the scale estimator for variable SEG_BIO_SCREEN1 because its scale estimator is less than

or equal to 0 before fuzzing.

I will try your option. But if there is a better way to convert all the missing values in all the numeric fields, I would want to try that.

Thanks,

saspert

Esteemed Advisor
Posts: 7,074

proc stdize errors

There is always the SAS suggested method: http://support.sas.com/kb/24/693.html

Respected Advisor
Posts: 3,773

proc stdize errors

Defining an ARRAY _NUMERIC_ will produce an ERROR similar to PROC STDIZE when there are no numeric variables.  I think checking using dictionary.columns or similar is good plus if there are no missing values the is no need to process further.

Super Contributor
Posts: 268

proc stdize errors

Great. I think I will try both the methods. Thank you for your suggestions, Art.

Respected Advisor
Posts: 3,773

proc stdize errors

You are going to have to define "better" better. 

PROC STDIZE is simple to code, quick enough for most and it is obvious what is being done REPONLY MISSING=0.  What could be simpler?

Perhaps you can address the missing to zeros problem proactively rather than reactively.

DATA=SEG_TOT_COMP_PGM_TR: this data name suggest to me it is some type of TRansposed TOTal COMPuted in the ProGraM.  Do you know about PRELOADFMT and or CLASSDATA=? 

Super Contributor
Posts: 268

proc stdize errors

Hi Data _null_,

Thank you for pointing out the flaw with using the SAS alternative. I think I will just stick with the original code + Art's macro check on the variables. When I say "better", I meant a more familiar routine. I am not that familiar with statistical procedures.

Thanks,
saspert.

Grand Advisor
Posts: 9,458

proc stdize errors

It is very strange, I run your code under my SAS9.2, It is OK, there is no ERROR or WARNING.

Here is another solution by using data step.

data temp;
 set sashelp.class;
 if _n_ in (2 4 6 8 ) then call missing(weight,height);
run;
%global list;
proc sql noprint;
 select name||'=coalesce('||name||',0);'
  into : list separated by ' '
   from dictionary.columns
    where libname='WORK' and memname='TEMP' and type='num';
quit;
data want;
 set temp;
 &list
run;

Ksharp

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 656 views
  • 6 likes
  • 4 in conversation