BookmarkSubscribeRSS Feed
Posterne
Fluorite | Level 6

Hello,

 

How do I convert large sets of data from character to numeric (for example), in a not too timeconsuming way?

 

Regards,

 

Datanoob.

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

What does your data look like?

ballardw
Super User

Are you in the same class the poster for this thread: https://communities.sas.com/t5/SAS-Procedures/Can-I-change-formats-of-several-variabels-in-one-proce...

 

I  ask because while this a moderately common question seldom do we get two people use phrasing of "changing format" when they actual task is "changing values".

 

Learning note: Format is a very specific concept in SAS related to the rules for displaying values. Look at online help for the FORMAT statement and PROC FORMAT.

 

Changing a SAS Format, which is a variable property, can be done quite easily with a Format statement which has syntax of

 

Format <variable list> formatname. ; If the variables are amenable to nice lists these aren't even very long:

 

Format var1-var100 F8.1 ; would assign a format to display all the numeric variables in the named range as 8 characters with one decimal position.

 

Changing that many variables VALUES usually means that the data was read incorrectly to begin with. Go back to the step the data was read and make sure the data was read in as needed. A common mistake is relying on Proc Import which guesses from examining a few rows of data and unless the first 20 rows contain the longest values then things often are not right. With text files use the GUESSINGROWS option to examine more rows to get better guesses.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 570 views
  • 0 likes
  • 3 in conversation