DATA Step, Macro, Functions and more

Error message when rename all variable

Reply
Super Contributor
Posts: 506

Error message when rename all variable

[ Edited ]

Hi Everyone,

It is so weird that the code below, which is posted in SAS support website, return error when I apply to my data.

Can you help me with that?

Thank you.

HHCFX

 

Original code


data one;
   input id name :$10. age score1 score2 score3 t;
   datalines;
1 George 10 85 90 8 9
2 Mary 11 99 98 9 1
3 John 12 100 100 10 0
4 Susan 11 78 89 10 0
;
run;
proc sql noprint;
   select cats(name,'=',name,'_OLD')
          into :list
          separated by ' '
          from dictionary.columns
          where libname = 'WORK' and memname = 'ONE'
          ;
quit;
proc datasets library = work nolist;
   modify one;
   rename &list;
quit;

All I did is to change the file name ONE into "Prj_master" and the SQL return message of NOTE: No rows were selected.

proc sql noprint;
   select cats(name,'=',name,'_OLD')
          into :list
          separated by ' '
          from dictionary.columns
          where libname = 'WORK' and memname = 'Prj_master'
          ;
quit;
proc datasets library = work nolist;
   modify prj_Master;
   rename &list;
quit;

15216
15217 proc import out= prj_Master
15218 datafile =
15218! "&export_folder.\&year&current_month.\&year.&current_month._Realtime_Report.xlsx"
15219 dbms = xlsx replace;
15220 sheet = "T6_Master_cost_no_PL";
15221 getnames = yes
15222 ;
15223 run;

NOTE: The import data set has 175 observations and 32 variables.
NOTE: WORK.PRJ_MASTER data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds


15224
15225
15226 proc sql noprint;
15227 select cats(name,'=',name,'_OLD')
15228 into :list
15229 separated by ' '
15230 from dictionary.columns
15231 where libname = 'WORK' and memname = 'Prj_master'
15232 ;
NOTE: No rows were selected.
15233 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

 

Super User
Posts: 24,004

Re: Error message when rename all variable

The code is case sensitive. 

Your table name should be all upper case.

 

 where libname = 'WORK' and memname = 'ONE'

Yours:

where libname = 'WORK' and memname = 'Prj_master'

I usually just upcase everything:

 

where libname = 'WORK' and upcase(memname) = upcase('Prj_master')

 

Super User
Super User
Posts: 8,279

Re: Error message when rename all variable

The values in LIBNAME and MEMNAME in the metadata tables is always in uppercase.

That is why no observations matched your search.

          where libname = 'WORK' and memname = 'PRJ_MASTER'
Ask a Question
Discussion stats
  • 2 replies
  • 93 views
  • 2 likes
  • 3 in conversation