BookmarkSubscribeRSS Feed
tejeshwar
Calcite | Level 5
Hi,

I have a dataset with around 600 attributes. Couple of them are numeric and others character. Is there a way I can convert all of them to character of length 20 in a single go?

Thanks
3 REPLIES 3
LinusH
Tourmaline | Level 20
I suggest that you write a macro that reads out all numeric variables in the table, create assignment statements using the put function, and drops the original numeric variables.
/Linus
Data never sleeps
LAP
Quartz | Level 8 LAP
Quartz | Level 8
There is a macro on tech support web site that does this...


http://support.sas.com/kb/22/218.html
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Do you presume that these SAS NUMERIC variables are decimal (using a SAS-default output FORMAT)? And where there is a specific output FORMAT, you would likely want to use that format in any "generated" code used with SAS DATA step assignment statements, as mentioned by Linus H. And, so, would the output be left-justified or right-justified in the SAS CHARACTER, length $20, converted variable values?

So, you could make use of the SAS-maintained views SASHELP.VCOLUMN to interrogate your tables, which could be used to generate SAS DATA step code for assigning the CHARACTER variables. After using SAS code to generate the SAS code out to a TEMP external (sequential) file, you would %INCLUDE that code to create the new SAS variables (possibly, hopefully in a different SAS table).

Of course, questions to ask: why do you want to do this? what is your quest?

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5394 views
  • 0 likes
  • 4 in conversation