BookmarkSubscribeRSS Feed
Mdormond
Calcite | Level 5

I'm working on a case control study and the cases and controls are identified using a letter at the end of the identification number. Some cases are matched 1:1 with controls and some are matched 1:2, or 1:3. A case/control pair may be identified as follows: GI111A, GI111B, GI111X with A and B denoting control status and X denoting case status. I want to perform analyses comparing cases and controls and therefore want to make a new variable "case status" defined by the ending letter. Is there a procedure I can use to scan the identification numbers and then identify cases and control, respectively? I haven't tried any code yet, I was just wondering if there was a quick and easy way to do this?

5 REPLIES 5
PGStats
Opal | Level 21

You could use:

case = char(id,length(id)) = "X";

in a datastep, where id is your identifier. The value of case will be 1 for cases and 0 for controls.

PG

PG
Mdormond
Calcite | Level 5

Would this create a new variable? Would I code it like creating a new variable?

PGStats
Opal | Level 21

Yes, the variable case would be created by the statement.You would use that variable in your analysis/models.

PG
Mdormond
Calcite | Level 5

What if all my preceding numbers are not the same length? I'm still confused on exactly how to code this?

PGStats
Opal | Level 21

Please post the SAS code you are using now to prepare your data for analysis and we'll take it from there.

PG

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 816 views
  • 0 likes
  • 2 in conversation