HomeSAS PROGRAMS

Changing the Case of All Character Variables in a Data Set1 min read

Like Tweet Pin it Share Share Email

This program will change the case for all of the character variables in a SAS data set. The key here is using the  _CHARACTER_ keyword in the ARRAY statement. This will create an array of all the character variables in the dataset.

Once the array is created, you can apply any character functions on all of the character variables.

data cars;
	set sashelp.cars;
	array Chars[*] _character_;

	do i=1 to dim(Chars);
		Chars[i]=upcase(Chars[i]);
	end;
	drop i;
run;

title "Listing the First 10 Observations in the Cars dataset";

proc print data=cars(obs=10 keep=_character_) noobs;
run;

Changing the Case of All Character Variables in a Data Set 1

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.