In my data set answers below zero each show a different type of missing value (e.g. not answered or not asked etc. from -1 to -10) and I want to replace them all with missing values.
I have made a global list named alist like this:
global alist Date Age Education Employment1 Employment2 Sex Stress1 Stress2 ///
JobControl1 JobControl2 JobControl3 JobDemand1 JobDemand2 JobDemand3 ///
Depression1 Depression2 Depression3 Depression4 Depression5 SocialSupport1 ///
SocialSupport2 SocialSupport3 SocialSupport4 SocialSupport5 SocialSupport6 ///
SocialSupport7 SocialSupport8 SocialSupport9 SocialSupport10
JobControl1 JobControl2 JobControl3 JobDemand1 JobDemand2 JobDemand3 ///
Depression1 Depression2 Depression3 Depression4 Depression5 SocialSupport1 ///
SocialSupport2 SocialSupport3 SocialSupport4 SocialSupport5 SocialSupport6 ///
SocialSupport7 SocialSupport8 SocialSupport9 SocialSupport10
foreach var of $alist {replace `var' =. if (`var'<=0)}
program error: code follows on the same line as open brace
Many thanks and appreciation.
0 Response to Adding missing values in a varlist
Post a Comment