BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buechler66
Barite | Level 11

Hi. I'm having trouble with my Rename statement.  It runs without error, but in the very next step where I use Proc Report with ODS only the _FREQ_ variable is renamed to FREQ in the output.  The other two variables don't appear to get renamed.

 

Any help would be greatly appreciated.

 

DATA &SITE._HCR_SUMMARY;
SET &SITE._SUMS_;
IF AREA = '' AND HCRID = '' AND PAY_DATA_MONTH = . AND ACTIVITY_DESCRIPTION = '' THEN ACTIVITY_DESCRIPTION = 'SITE TOTAL'; 
IF AREA NE '' AND HCRID NE '' AND PAY_DATA_MONTH = . AND ACTIVITY_DESCRIPTION = '' THEN ACTIVITY_DESCRIPTION = 'HCR CONTRACT TOTAL'; 
IF AREA NE '' AND HCRID NE '' AND PAY_DATA_MONTH NE . AND ACTIVITY_DESCRIPTION = '' THEN ACTIVITY_DESCRIPTION = 'MONTHLY CONTRACT TOTAL'; 
DROP _TYPE_;
RENAME _FREQ_=FREQ PAY_DATA_MONTH=MONTH_PAY_DATA RATE=RATE_PER_UNIT;
FORMAT PAY_AMOUNT DOLLAR15.2 RATE DOLLAR15.2 UNITS COMMA15.2;
RUN;


/* EXPORT THE FILE TO XLS USING ODS
   NOTE FOR OLDER VERSIONS OF SAS YOU COULD USE ODS TAGSETS.EXCELXP FILE="C:\TEST.XML";
   TO GET THE SAME RESULT 
*/
ODS EXCEL FILE="C:\USERS\STEVEBUECHLER\BOX SYNC\IBM\USPS\HRC PAY DATA ANALYSIS\&SITE._HCR_PD_SUMMARY.XLSX";
PROC REPORT DATA=&SITE._HCR_SUMMARY;
  COLUMNS _ALL_;
RUN;
ODS EXCEL CLOSE;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

PROC REPORT is likely defaulting to the labels.

Strip all the labels from the data to force the variable names to show.

 

 

proc datasets lib=work memtype=data;
   modify &SITE._HCR_SUMMARY;
     attrib _all_ label=' ';
run;
quit;

 

Then run your proc REPORT.

 

I haven't tried it but you could also try adding the 

 

attrib _all_ label='';

 line to your data step and see if that removes all the labels.

 

 

View solution in original post

3 REPLIES 3
Reeza
Super User

PROC REPORT is likely defaulting to the labels.

Strip all the labels from the data to force the variable names to show.

 

 

proc datasets lib=work memtype=data;
   modify &SITE._HCR_SUMMARY;
     attrib _all_ label=' ';
run;
quit;

 

Then run your proc REPORT.

 

I haven't tried it but you could also try adding the 

 

attrib _all_ label='';

 line to your data step and see if that removes all the labels.

 

 

buechler66
Barite | Level 11
Worked like a charm. Thanks so much for taking the time to help!
ballardw
Super User

Another approach:

/* instead of */
RENAME _FREQ_=FREQ PAY_DATA_MONTH=MONTH_PAY_DATA RATE=RATE_PER_UNIT;
/* change the label*/
label _FREQ_="FREQ" 
      PAY_DATA_MONTH="MONTH PAY DATA" 
      RATE="RATE PER UNIT"
;

Note use of slightly nicer text in the label vs variable name.

 

And who restarted the school of programming everything in capital letters???

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 1355 views
  • 1 like
  • 3 in conversation