BookmarkSubscribeRSS Feed
hhchenfx
Barite | Level 11

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

 

 

2 REPLIES 2
Reeza
Super User

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')

 

Tom
Super User Tom
Super User

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'

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 730 views
  • 2 likes
  • 3 in conversation