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

Separating data points

Accepted Solution Solved
Reply
Super Contributor
Posts: 307
Accepted Solution

Separating data points

 

 Hello Madam/Sir,

 

I have this data set with variables Meds1-Meds10.

I have to create 10 other variables Medi1-Medi10 such that Medi1-Medi10 should have only the name of the medication, that is the first character variable. For example in obs 1,  Meds1,  the first data point is LIPITOR 10MG TABLET. This will be Lipitor. That is 10MG TABLET deleted. The case like in obs 3, Meds2, the BUDESONIDE will stay BUDESONIDE in the new name Medi2.

 

SAS DATA

Obs Meds1 Meds2 Meds3 Meds4 Meds5 Meds6 Meds7 Meds8 Meds9 Meds10
1 LIPITOR 10 MG TABLET BUDESONIDE COREG 12.5 MG TABLET NEXIUM 20 MG CAPSULE,DELAYED RELEASE FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION ISOSORBIDE MONONITRATE ER 60 MG TABLET,EXTENDED RELEASE 24 HR LEVALBUTEROL HFA 45 MCG/ACTUATION AEROSOL INHALER LEVALBUTEROL 0.63 MG/3 ML SOLUTION FOR NEBULIZATION LISINOPRIL 20 MG
2 ALBUTEROL SULFATE HFA 90 MCG/ACTUATION AEROSOL INHALER AMLODIPINE 10 MG TABLET ATORVASTATIN 10 MG TABLET LIPITOR 20 MG TABLET BUDESONIDE COREG 25 MG TABLET NEXIUM 20 MG CAPSULE,DELAYED RELEASE FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION LISINOPRIL 20 MG LORATADINE 10 MG TABLET
3 LIPITOR 10 MG TABLET BUDESONIDE ESOMEPRAZOLE MAGNESIUM 20 MG CAPSULE,DELAYED RELEASE FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION ISOSORBIDE MONONITRATE ER 60 MG TABLET,EXTENDED RELEASE 24 HR LEVALBUTEROL HFA 45 MCG/ACTUATION AEROSOL INHALER LISINOPRIL 20 MG LORATADINE 10 MG TABLET METOPROLOL TARTRATE 25 MG TABLET VERAPAMIL ER (SR) 240 MG TABLET,EXTENDED RELEASE
4 ALBUTEROL SULFATE HFA 90 MCG/ACTUATION AEROSOL INHALER AMLODIPINE 10 MG TABLET ATORVASTATIN 10 MG TABLET LIPITOR 20 MG TABLET BUDESONIDE CARVEDILOL 25 MG TABLET NEXIUM 20 MG CAPSULE,DELAYED RELEASE FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION ISOSORBIDE MONONITRATE ER 60 MG TABLET,EXTENDED RELEASE 24 HR LISINOPRIL 20 MG
5 LIPITOR 10 MG TABLET BUDESONIDE ESOMEPRAZOLE MAGNESIUM 20 MG CAPSULE,DELAYED RELEASE FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION ISOSORBIDE MONONITRATE ER 60 MG TABLET,EXTENDED RELEASE 24 HR LEVALBUTEROL HFA 45 MCG/ACTUATION AEROSOL INHALER LISINOPRIL 20 MG LORATADINE 10 MG TABLET METOPROLOL TARTRATE 25 MG TABLET VERAPAMIL ER (SR) 240 MG TABLET,EXTENDED RELEASE
6 ALBUTEROL 90 MCG/ACTUATION AEROSOL INHALER EXFORGE HCT 10 MG CALCIUM 600 + D(3) 600 MG (1,500 MG) VITAMIN D2 50,000 UNIT CAPSULE CENTRUM ORAL GABAPENTIN 100 MG CAPSULE FISH OIL 1,000 MG CAPSULE FLUTICASONE 110 MCG/ACTUATION HFA AEROSOL INHALER FAMOTIDINE 20 MG TABLET GABAPENTIN 100 MG CAPSULE
7 EXFORGE HCT 10 MG CALCIUM 600 + D(3) 600 MG (1,500 MG) CARVEDILOL 3.125 MG TABLET FAMOTIDINE 20 MG TABLET FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION CENTRUM ORAL FUROSEMIDE 20 MG TABLET GABAPENTIN 100 MG CAPSULE GABAPENTIN 100 MG CAPSULE LEVOCETIRIZINE 5 MG TABLET
8 AMLODIPINE 10 MG TABLET EXFORGE HCT 10 MG CALCIUM 600 + D(3) 600 MG (1,500 MG) CARVEDILOL 3.125 MG TABLET FAMOTIDINE 20 MG TABLET FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION CENTRUM ORAL GABAPENTIN 100 MG CAPSULE GABAPENTIN 100 MG CAPSULE CLARITIN 10 MG TABLET
9 PROVENTIL HFA 90 MCG/ACTUATION AEROSOL INHALER ALBUTEROL 90 MCG/ACTUATION AEROSOL INHALER EXFORGE HCT 10 MG CALCIUM 600 + D(3) 600 MG (1,500 MG) FAMOTIDINE 20 MG TABLET CENTRUM ORAL GABAPENTIN 100 MG CAPSULE FISH OIL 1,000 MG CAPSULE FLUTICASONE 50 MCG/ACTUATION NASAL SPRAY,SUSPENSION EXFORGE HCT 10 MG
10 ALBUTEROL SULFATE HFA 90 MCG/ACTUATION AEROSOL INHALER ALBUTEROL 90 MCG/ACTUATION AEROSOL INHALER EXFORGE HCT 10 MG EXFORGE HCT 10 MG FAMOTIDINE 20 MG TABLET GABAPENTIN 100 MG CAPSULE CLONIDINE HCL 0.1 MG TABLET CENTRUM ORAL FISH OIL 1,000 MG CAPSULE CALCIUM 600 + D(3) 600 MG (1,500 MG)

Accepted Solutions
Solution
a week ago
PROC Star
Posts: 440

Re: Separating data points

[ Edited ]
Posted in reply to desireatem

med1=scan(med1,1) and similar thing should work if it is only value. if you want to extract the value till the number then

data lll;
retain pattern;
IF _N_ =1 THEN PATTERN = PRXPARSE ("/([^0-9]+)/");
input a $50.;
if prxmatch(pattern, a) then
call prxposn(pattern, 1, position, length);
val = substr(a,position, length);
drop pattern position length;
datalines;
my medicine 345
medicine 293
my medicine nice 76 this
;

View solution in original post


All Replies
Solution
a week ago
PROC Star
Posts: 440

Re: Separating data points

[ Edited ]
Posted in reply to desireatem

med1=scan(med1,1) and similar thing should work if it is only value. if you want to extract the value till the number then

data lll;
retain pattern;
IF _N_ =1 THEN PATTERN = PRXPARSE ("/([^0-9]+)/");
input a $50.;
if prxmatch(pattern, a) then
call prxposn(pattern, 1, position, length);
val = substr(a,position, length);
drop pattern position length;
datalines;
my medicine 345
medicine 293
my medicine nice 76 this
;
Highlighted
Super User
Posts: 12,148

Re: Separating data points

Posted in reply to desireatem

So what do you want for the medi value from ALBUTEROL SULFATE HFA 90 MCG/ACTUATION AEROSOL INHALER?

If you only want ALBUTEROL then the scan function works fine. If you want more  then much more work may be needed, such as defining how we know which part is actually needed for the longer compound names.

☑ This topic is solved.

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

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