I need help in converting variable type from character to numeric. I want to concatenate 3 datasets but I then discover that one variable defined as numeric in 2 of the datasets while it was character in the 3rd datasets. How do i go about this?
Thanks.
fadtt
You can use input function to convert Character values to Numeric values. You may change the informat based on your data.
For e.g. numvar = input(charvar,best.);
Thanks, I already tried the input function but the type did not change thereby preventing me from concatenating the datasets.
It would help if you can post your sample data and code.
Thanks NickR,
I tried it again and it worked. I was amazed. I appreciate it.
fadtt
Fadtt,
This post would be better in the SAS Macro, Data Step... Community. This community is for getting started with using Communities, not for getting started with using SAS.
You got your answer, and that's good, but more people would have seen it in the other forum.
Doc Muhlbaier
Duke
Did I offend you by posting my question because I don't understand your comment.
No offense at all. I saw you hadn't posted before and was offering a suggestion for more effective posting.
There are lots of Forums for posting questions at http://communities.sas.com/index.jspa . The one that is most pertinent to your question is "SAS Macro Facility, Data Step, and SAS Language Elements".
This Forum ("Getting Started: Community Instructions, Usage Tips, and Feedback") is designed for comments and questions about how to use the SAS Communities system itself. Right now, because SAS just moed to this platform, there are a lot of people watching this forum. As people get more comfortable with the process, there are likely to be fewer and fewer people looking at it to be available to answer SAS usage questions.
Doc Muhlbaier
Duke
I appreciate your advise. I am a bit new to discussion forum but I needed help at the time I just decided to make use of what I have on hand.
another way to change Character variable to numeric variable,
Char_Var *1;
or Char_Var+0;
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.