SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Separate alphanumeric and numeric values in a single variable

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

Separate alphanumeric and numeric values in a single variable

I have a dataset with following variables:

Patient_ID        Class      Gender

015786                10          Male

012345                20          Female

0T7896                10          Female

45J056                50          Male

7895P7                05          Female

and so on.

 

I need to output a dataset based on alphanumeric values in variable Patient_ID as one dataset and all numeric variables in Patients_ID as another dataset.

 

Please advise.

 

 


Accepted Solutions
Solution
‎03-23-2018 11:20 AM
PROC Star
Posts: 1,288

Re: Separate alphanumeric and numeric values in a single variable

Posted in reply to pmpradhan
data Numeric Alpha;
	set have;

	if findc(Patient_ID, "", "dks") > 0 then
		output Alpha;
	else output Numeric;
run;

View solution in original post


All Replies
Super User
Posts: 9,873

Re: Separate alphanumeric and numeric values in a single variable

Posted in reply to pmpradhan

Use notdigit(strip(patient_id)) to determine where to write a specific observation.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎03-23-2018 11:20 AM
PROC Star
Posts: 1,288

Re: Separate alphanumeric and numeric values in a single variable

Posted in reply to pmpradhan
data Numeric Alpha;
	set have;

	if findc(Patient_ID, "", "dks") > 0 then
		output Alpha;
	else output Numeric;
run;
Contributor
Posts: 34

Re: Separate alphanumeric and numeric values in a single variable

Brilliant! Works Perfectly! Thank you TomKari!! Smiley Happy

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 135 views
  • 1 like
  • 3 in conversation