BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi everyone, 

I'm trying to add a suffix to all column names in a dataset. I'm following the code (example 2) here. I have never used proc SQL before. The first portion of the code (the sql part) seems to run ok (no error messages). When I run the second part (proc datasets), I get the following messages: 


86 proc datasets library = work nolist;
87 modify meanCPUAbottomfish;
WARNING: Apparent symbolic reference LIST not resolved.
88 rename &list; run;
NOTE: Enter RUN; to continue or QUIT; to end the procedure.
ERROR 22-322: Expecting a name.
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: Statements not processed because of errors noted above.
89 quit; 
How do I fix this error? Thanks. 
Super User
It's saying your macro variable list doesn't exist.
Please show how you created the macro variable, the log and the output from the following, before the PROC DATASETS proc:

%put &list.;

Calcite | Level 5
Hi, thank you so much for replying. I actually just tried the code again with the dataset name capitalized and it worked...?

Here's the code:
/* Example 1: */
/* This code creates a macro variable &list with the list of variables in the form. */
/* id = id_OLD */
/* This format could be used to add a suffix to all the variables. */
proc sql noprint;
select cats(name,'=',name,'_bottom')
into :list
separated by ' '
from dictionary.columns
where libname = 'WORK' and memname = 'MEANCPUABOTTOMFISH';
/* Use PROC DATASETS to do the rename using the macro variable you have created. */
/* Modify the libref and data set name for your data set. */;
proc datasets library = work nolist;
modify meanCPUAbottomfish;
rename &list; run;
/* Verify the changes with a PROC CONTENTS on your data set. */
proc contents data = MEANCPUABOTTOMFISH;
Super User
That is correct, if you look in Dictionary.Columns table it always stores the libname and memname in upper case letters.
Happy to hear your issue is resolved.

A somewhat safer method in the long run is to up case your comparison all the time, but that can add some extra time to the query.

libname = upper('WORK') and memname = upper('MEANCPUABOTTOMFISH');

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
  • 3 replies
  • 2 in conversation