BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vraj1
Quartz | Level 8

I have a variable which has format $TDRUG41. and informat $41.

 

i want to filter 

data ind;
set girdata;
if drug_id="DRUG 2";
run;

 

Somehow this is not working. Can anyone help me.

1 ACCEPTED SOLUTION

Accepted Solutions
vraj1
Quartz | Level 8

yes it worked 🙂

 

Thanks a lot

View solution in original post

10 REPLIES 10
EH
Obsidian | Level 7 EH
Obsidian | Level 7

Hello vraj1,

 

Probably "DRUG 2" is one of the formatted values of drug_id.

In that case:

 

if put(drug)id, $tdrug41.) = 'DRUG 2";

 

 

will do.

 

Otherwise please attach a small piece of the data and code.

 

Hope this helps,

Eric

vraj1
Quartz | Level 8

The code which you had sent is not working somehow. It is running from 10 mins.

 

 

EH
Obsidian | Level 7 EH
Obsidian | Level 7
Maybe because of my typo using different quote symbols :-(. It should be ' ' or " ". Sorry...
vraj1
Quartz | Level 8

No 🙂 i corrected it but still.

 

if put(drug_id, $tdrug41.) = "Biphasic Insulin Aspart 30";

EH
Obsidian | Level 7 EH
Obsidian | Level 7
and another typo which you must have seen, drug_id... Not my day today 😉
EH
Obsidian | Level 7 EH
Obsidian | Level 7

Maybe you can add a few lines of data and also a few lines of the format definition. It may be something like variable length of uppercase/lowercase. Dirty work...

 

Eric

vraj1
Quartz | Level 8


data ind;
set girdata;
*if drug_id="Biphasic Insulin Aspart 30";
if put(drug_id, $tdrug41.) = "Biphasic Insulin Aspart 30";
run;

 


Capture11.JPG
EH
Obsidian | Level 7 EH
Obsidian | Level 7
Try without 41, only $tdrug.
vraj1
Quartz | Level 8

yes it worked 🙂

 

Thanks a lot

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Just want to add two points to this.  Firstly, if @EH solution worked, its good form to mark his post as the result, both so other people can see the solution and so he gets some points for the effort.  Secondly, why are you attempting to find a drug name via formats?  If you need to use drug information you are far better off using coded data using WHO Drug coding.  I would be suprised if you didn't have this autoencoding on the database.  It allows you to find specific drugs/drug groups regardless of typos in the data, different product names etc.  your example for instance could be Biphasic Insulin Aspart, your code wouldn't pick it up.  Also, you then need to separately maintain your formats catalog, i.e. re-inventing the wheel.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1215 views
  • 0 likes
  • 3 in conversation