Changing the Case of All Character Variables in a Data Set

Changing the Case of All Character Variables in a Data Set

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;

Output:

Changing the Case of All Character Variables in a Data Set

Every week we'll send you SAS tips and in-depth tutorials

JOIN OUR COMMUNITY OF SAS Programmers!

Subhro

Subhro provides valuable and informative content on SAS, offering a comprehensive understanding of SAS concepts. We have been creating SAS tutorials since 2019, and 9to5sas has become one of the leading free SAS resources available on the internet.

Leave a Reply

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