OHDSI Home | Forums | Wiki | Github

If-Then in SQLRender

@schuemie or anyone else,

http://ohdsi.github.io/SqlRender/articles/UsingSqlRender.html#if-then-else

Is there a way to put two cases into the if-then in SqlRender?

I want to do something like {@z == 1 && @i == 1}?{}

You just need to use 1 ampersand:

{@z == 1 & @i == 1}?{}

example:

sql <- "select {@z == 1 & @i == 1}?{'hi Erica'}"
sql <- SqlRender::renderSql(sql = sql, z = 1, i = 1)$sql

produces

[1] "select 'hi Erica'"
1 Like

Ha! Thanks @Ajit_Londhe!

@schuemie - this might be nice example to add to vignette so when I forget in 6 months I won’t do it again. :smile:

1 Like

Done

t