DATA Step, Macro, Functions and more

problems with formatting

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 115
Accepted Solution

problems with formatting

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.


Accepted Solutions
Solution
‎01-11-2016 08:14 AM
Frequent Contributor
Posts: 115

Re: problems with formatting

yes it worked Smiley Happy

 

Thanks a lot

View solution in original post


All Replies
Contributor EH
Contributor
Posts: 32

Re: problems with formatting

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

Frequent Contributor
Posts: 115

Re: problems with formatting

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

 

 

Contributor EH
Contributor
Posts: 32

Re: problems with formatting

Maybe because of my typo using different quote symbols :-(. It should be ' ' or " ". Sorry...
Frequent Contributor
Posts: 115

Re: problems with formatting

No Smiley Happy i corrected it but still.

 

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

Contributor EH
Contributor
Posts: 32

Re: problems with formatting

and another typo which you must have seen, drug_id... Not my day today ;-)
Contributor EH
Contributor
Posts: 32

Re: problems with formatting

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

Frequent Contributor
Posts: 115

Re: problems with formatting


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

 


Capture11.JPG
Contributor EH
Contributor
Posts: 32

Re: problems with formatting

Try without 41, only $tdrug.
Solution
‎01-11-2016 08:14 AM
Frequent Contributor
Posts: 115

Re: problems with formatting

yes it worked Smiley Happy

 

Thanks a lot

Super User
Super User
Posts: 7,401

Re: problems with formatting

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.

☑ This topic is SOLVED.

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

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