DATA Step, Macro, Functions and more

Avoid WARNING from the code without changing variables name or Code Structure

Reply
Contributor
Posts: 52

Avoid WARNING from the code without changing variables name or Code Structure

Hi All,

I have prepared below code for some Purpose, Code is working fine as per Expectation ,Since Warning takes place In final Step of code .

Please Do helpful to avoid Below Code warning Without changing Code Structure Or variables, Please Find Below Code.



data Dc;

  Length name $ 50 Surname $ 50 ;

  Infile datalines missover;

  Input Name $ surname $ num ft;

  datalines;

ramesh Babu 3333 1

Dishant parikh 33 22

Disha.N Khanna 33 3

MAk Shah 3 44

Jack Sandy 30 567

;

Run;

%macro DC_(dcds=,dc=);

*** to Find Data Type ***;

  proc contents data=&dcds order=varnum out=&dcds.var(keep=name varnum type) noprint; Run;

  proc sort data =&dcds.var ;

  By varnum;

  RUn;

*** For Numeric to character ***;

  Proc Sql noprint; Select count(distinct type) into: dc_cnt_num from &dcds.var where type =1; Quit;

  %if &dc_cnt_num > 0 %then %do;

  data &dcds.var_Num;

  Set &dcds.var;

  if type =1;

  do i = 1 to &dc_cnt_num ;

  newname=trim(left(name))||"_DC";

  End;

  Run;

                                         

  proc sql noprint;                                        

  select trim(left(name)), trim(left(newname)),            

        trim(left(name))||'='||trim(left(newname))        

  into Smiley Very HappyCc_list separated by ' ', Smiley Very HappyCn_list separated by ' ', 

      Smiley Very HappyCrenam_list separated by ' '                        

  from &dcds.var_Num;                                               

  quit;                                                                                                              

  data &dcds;                                              

  set &dcds;                                                

  array ch(*)  &DCc_list;                                   

  array nu(*) $ &DCn_list;                                     

  do i = 1 to dim(ch);                                     

  nu(i)=cats(ch(i),"");   end;                                                     

  drop  i &DCc_list;                                          

  rename &DCrenam_list;                                                                                     

  run;

%end;

%mend;

%DC_(dcds=dc,dc=name surname num ft);

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

NOTE: PROCEDURE CONTENTS used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

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

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

NOTE: PROCEDURE SORT used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

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

NOTE: The data set WORK.DCVAR_NUM has 2 observations and 5 variables.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

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

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

NOTE: There were 5 observations read from the data set WORK.DC.

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

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

Please Help me to avoid Above WARING Thanks In advance For Ur help.

Occasional Contributor Aad
Occasional Contributor
Posts: 8

Re: Avoid WARNING from the code without changing variables name or Code Structure

If you just run this program with one additional statement, you see what code is generated by the macro.

Add this statement ahead of the first line in your program and you see exactly what happens:

OPTIONS MPRINT;

Contributor
Posts: 52

Re: Avoid WARNING from the code without changing variables name or Code Structure

Thanks Aad Problem Solved.

Ask a Question
Discussion stats
  • 2 replies
  • 247 views
  • 3 likes
  • 2 in conversation