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.
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
The code which you had sent is not working somehow. It is running from 10 mins.
No 🙂 i corrected it but still.
if put(drug_id, $tdrug41.) = "Biphasic Insulin Aspart 30";
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
data ind;
set girdata;
*if drug_id="Biphasic Insulin Aspart 30";
if put(drug_id, $tdrug41.) = "Biphasic Insulin Aspart 30";
run;
yes it worked 🙂
Thanks a lot
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.