Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to convert ssn to gender

So, I'm very new to Qlikview, and I've spent way too much time on this very small problem.. Hope a kind soul can help me find the best sollution.

I've got SSNs, consisting of 10 numbers (like DDMMYY7890), where the ninth number tells me the gender of the person. If the 9th number is an odd number, the person is a male, and if it is an even number the person is female.

My question is where and how I can make a variable consisting of male vs female? Not sure if this is best resolved in the loading script or as an expression..

Any good hints to best practice, please?

1 Reply
trdandamudi
Master II
Master II

If you need in the front end on chart, you can use the below expression:

=If(Odd(mid(SSN,9, 1 )),'Male','Female')

If you need it in the script then below is the code:

Data:
Load *,
If(Odd(mid(SSN,9, 1 )),'Male','Female') as Gender;
Load * Inline [
ID, Customer,AMOUNT,SSN
100,Hapag Llyod,1000,DDMMYY7890
200,Maersk,2000,DDMMYY7820
]
;

Hope this helps..