Write and run SAS programs in your web browser

How to convert format from character to numeric variable

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

How to convert format from character to numeric variable

proc sort data=hw4.demographic
          out=work.demographic;
   by ID;
run;

proc sort data=hw4.survey2
          out=work.survey2;
   by ID;
run;

data work.demo2_ydu18;
   merge work.demographic work.survey2;
   by ID;
run;

ID in demographic is character and in survey2 is numeric. I want to merge those two data set, could anyone tell how to convert one of those type. I tried ID=input(ID, 3.0); in demographic but it did not work. 


Accepted Solutions
Solution
‎07-09-2017 01:13 PM
PROC Star
Posts: 7,492

Re: How to convert format from character to numeric variable

data demographic;
  input id $;
  cards;
1
2
3
;

data demographic (drop=_id);
  set demographic (rename=(id=_id));
  id=input(_id,3.);
run;

Art, CEO, AnalystFinder.com

 

View solution in original post


All Replies
Solution
‎07-09-2017 01:13 PM
PROC Star
Posts: 7,492

Re: How to convert format from character to numeric variable

data demographic;
  input id $;
  cards;
1
2
3
;

data demographic (drop=_id);
  set demographic (rename=(id=_id));
  id=input(_id,3.);
run;

Art, CEO, AnalystFinder.com

 

Contributor
Posts: 23

Re: How to convert format from character to numeric variable

Thank you, it works.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 195 views
  • 0 likes
  • 2 in conversation