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

I am outputting a dataset into Excel and am trying to get all of the values within each cell to be uppercase. The problem is that some variables are codelisted and those decode values are not uppercase, e.g. 'Not related'. I am stuck working with the format catalog with those mixed case codelists and tried running an array to change them but it seems that is only upcasing the value in the variables and not the codelisted value which I suppose makes sense. Is there a style/option within ODS that I can use to set everything to be uppercase?

 

 

*opens excel output;

ods _all_ close;

ods excel file= "YOUR FILE PATH HERE.xlsx"
options(
sheet_interval="none"
sheet_name="&sysdate."
frozen_headers="1"
autofilter='on'
);

options nolabel;
options missing='.';

proc report data=cm_studyname_ready style(column header)=[textalign=left verticalalign=top]
style(Header)=[background=#FFCC99]
style(header)=[font_weight=bold height=.4in]
;

run;

ods excel close;

*opens destination again - choose the ones you need;

ods html;
ods listing;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

If your formats are simple 1='High' 2='Low' type formats then you could use PROC FORMAT to convert the formats to a dataset. Upcase the labels and then create new formats.

proc format lib=mylib.myformats cntlout=formats; run;
data formats ;
 set formats;
 label=upcase(label);
run;
proc format lib=work.upcase_formats cntlin=formats; run;
options insert=(fmtsearch=(work.upcase_formats));

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

You can use the compute block to upcase the variables as below , this is just an example

 


proc report data=cm_studyname_ready style(column header)=[textalign=left verticalalign=top]
style(Header)=[background=#FFCC99]
style(header)=[font_weight=bold height=.4in]
;
column company ;
define company / computed;
compute company;
company=upcase(compute);
endcomp; 
run;

 

 

Thanks,
Jag
PaigeMiller
Diamond | Level 26

You can change the values of the variable in data set CM_STUDYNAME_READY to uppercase in a data step before running PROC REPORT. Use the UPCASE function.

--
Paige Miller
Reeza
Super User
There's an upcase format.

Apply the formats in a prior step. If you have variables that are numeric and have formats applied you'll need a different approach.

format _character_ $upcase.;
Tom
Super User Tom
Super User

Your code snippet shows PROC REPORT.  Do you really need to make a "report" or are you just dumping the data into a spreadsheet?

Do you need Excel or could you produce a simple text file, like a CSV file?

 

It might be easier to post process the output. That would be really easy for a text file.

filename csv temp;
data _null_;
  file csv dsd ;
  set sashelp.class ;
  put (_all_) (+0) @;
  _file_=upcase(_file_);
  put;
run;
690   data _null_;
691     infile csv ;
692     input;
693     put _infile_;
694   run;

NOTE: The infile CSV is:

      Filename=...\#LN00073,
      RECFM=V,LRECL=32767,File Size (bytes)=403,
      Last Modified=04Sep2019:11:10:06,
      Create Time=04Sep2019:11:10:06

ALFRED,M,14,69,112.5
ALICE,F,13,56.5,84
BARBARA,F,13,65.3,98
CAROL,F,14,62.8,102.5
HENRY,M,14,63.5,102.5
JAMES,M,12,57.3,83
JANE,F,12,59.8,84.5
JANET,F,15,62.5,112.5
JEFFREY,M,13,62.5,84
JOHN,M,12,59,99.5
JOYCE,F,11,51.3,50.5
JUDY,F,14,64.3,90
LOUISE,F,12,56.3,77
MARY,F,15,66.5,112
PHILIP,M,16,72,150
ROBERT,M,12,64.8,128
RONALD,M,15,67,133
THOMAS,M,11,57.5,85
WILLIAM,M,15,66.5,112
NOTE: 19 records were read from the infile CSV.
      The minimum record length was 17.
      The maximum record length was 21.
Tom
Super User Tom
Super User

If your formats are simple 1='High' 2='Low' type formats then you could use PROC FORMAT to convert the formats to a dataset. Upcase the labels and then create new formats.

proc format lib=mylib.myformats cntlout=formats; run;
data formats ;
 set formats;
 label=upcase(label);
run;
proc format lib=work.upcase_formats cntlin=formats; run;
options insert=(fmtsearch=(work.upcase_formats));

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
  • 5 replies
  • 2330 views
  • 4 likes
  • 5 in conversation