@NewUsrStat wrote:
Hi guys,
I'm using the following code to format all my char variables so that they will appear as uppercase:
proc datasets lib=work nolist;
modify mydb;
format _character_ $upcase.;
run;
quit;
1) While doing proc contents, the $UPCASE appears. Is it possible to prevent it appears in "Format"? Empty will be ok.
2) Is there a way to exclude a specific char variable to be formatted as "upcase"?
Note that I used this code because I have many many variables and I cannot specify each one one by one.
Thank you in advance
To your last point use some code generation instead so that you do not need to know the names of all of the variables.
For example say you wanted to make a new dataset that converted all of the character variables except NAME to uppercase you could do something like this.
proc contents noprint data=mydb out=contents;
run;
filename code temp;
data _null_;
set contents ;
where type=2;
where also upcase(name) ne 'NAME';
file code;
put name '=upcase(' name ');';
run;
data want;
set mydb;
%include code / source2;
run;
Note to protect for nonstandard variable names in case you are running with VALIDVARNAME=ANY then you could modify the data _NULL_ code to generate name literals instead.
nliteral=nliteral(name);
put nliteral '=upcase(' nliteral ');';