Sas to pandas

How do I write below sas code to python
If type in (1,4,5,6) then flag=1;
Else if substr(source,1,1)=A or substr(source,1,2)=CA then flag=1;
Else flag=0;

You can see some syntax in sas…can u tell me the best way to write in pandas

Hi @elan98765,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information.

As you’ll notice, your topic is now here in the Programming Help and Discussion board. No action is needed on your part; you can continue the conversation as normal here.

Cheers!