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¤t_month.\&year.¤t_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
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')
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'
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.