BookmarkSubscribeRSS Feed
alamrikd
Calcite | Level 5

Hello,

I am using FAERS database for my project. I am trying to select only one drug from the variable "drugname". I used where and if statments but I get error all the time.

 

Here is my code:

libname kete'c:\users\alamrikd\Desktop';
run;


data kete.drug12q4;
infile 'c:\users\alamrikd\Desktop\DRUG13Q1.txt' dlm='$' dsd truncover firstobs=2;
input
primaryid :$10.
caseid :$8.
drug_seq
role_cod :$2.
drugname :$30.
prod_ai :$50.
val_vbm :$1.
route :$10.
dose_vbm :$30.
cum_dose_chr
cum_dose_unit :$7.
dechal :$1.
rechal :$1.
lot_num :$20.
_exp_dt :$10.
@
;
run;

proc contents data = kete.drug12q4;
run;
proc print data=kete.drug12q4(obs=3);

run;

 

data kete.metformin;
set kete.drug12q4;
where drugname = 'metformin';
run;

 

 

I want select only observations for metformin, could you help me how to subset the data based on that?

 

Thank you

1 REPLY 1
andreas_lds
Jade | Level 19

Please post the log of all the steps using "insert code" button.

Are you sure that the value is written in all lowercase?

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 731 views
  • 0 likes
  • 2 in conversation