Please have a look at the Dataset which is in Work library. I am working on this Dataset, I need to convert all these values in 12.5 numeric format. These variables are already in numeric format. What code to include after Data yyy; set zzz; ... to make the change? Much thanks.
please post the data is a SAS datastep. It is hard to read a picture.
Must repeat, what @VDD already requested: post the data as datastep using datalines-statement, so that we know what type the variables are. There is a huge difference between applying a format and converting data. And to suggest something for the later, we need something to work with. Another option for you: use the search-facility in the community. Converting text to numbers has been explained so many times, that you will, most likely, find adaptable code.
@d6k5d3 wrote:
By the way, I just imported the data. And after importing, it looks like this. I want to make the changes in a data step.
If you have an existing SAS data set you can change properties of variables in place with Proc DATASETS. You can rename variables, change formats, informats and labels.
a brief example creating a copy of a data set you should have:
Data work.class; set sashelp.class; run; proc datasets lib=work; modify class; format height f8.4 weight f12.2 ; quit;
the LIB on the proc statement is the library the dataset(s) you want to modify are in.
The Modify statement indicates which dataset you are going to modify.
The format statement assigns the format to the variable. If you want to have the same format for multiple variables then
proc datasets lib=work; modify class; format height weight best8. ; quit;
Informat or Label statements work the same. You can have another block of modify statements for another data set.
The QUIT is used to end the procedure because Datasets is one of the procedures that allows multiple Run groups.
@ballardw, thank you very much for the reply. I believe your code would work great. But a little change in the plan. I would import the data from a csv file, and all the figures you see would be in CHAR format.
So when I would go to modify the dataset, and format the variables to numeric, SAS would give me an error for trying to convert from CHAR to numeric.
What code would you suggest in the format line for conversion from CHAR to numeric?
I appreciate your time.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.