BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
saspert
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

8 REPLIES 8
art297
Opal | Level 21

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;

saspert
Pyrite | Level 9

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

art297
Opal | Level 21

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

data_null__
Jade | Level 19

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.

saspert
Pyrite | Level 9

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

data_null__
Jade | Level 19

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=? 

saspert
Pyrite | Level 9

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.

Ksharp
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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