BookmarkSubscribeRSS Feed
dishant
Calcite | Level 5

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 :DCc_list separated by ' ', :DCn_list separated by ' ', 

      :DCrenam_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.

2 REPLIES 2
Aad
Calcite | Level 5 Aad
Calcite | Level 5

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 940 views
  • 3 likes
  • 2 in conversation