Below is my data. "residuals" are all the negative numbers and I created another variable "dummy" which takes the value of 1 if "residuals" are greater than -0.0138 using this code: gen dummy = residuals >-0.0138.

Problem is that dummy is even created for the variables which are missing and are represented by ".". What to do? Thanks.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long firmid int Time float(residuals dummy)
 1 2010         . 1
 1 2011         . 1
 2 2005 -.0079591 1
 2 2006 -.0141499 0
 2 2007 -.0419742 0
 2 2008 -.0442654 0
 2 2009 -.0545213 0
 2 2010 -.0295039 0
 2 2011 -.0023729 1
 3 2008 -.0132925 1
 3 2009  -.004249 1
 3 2010 -.0263323 0
 4 2005  -.024182 0
 4 2006 -.0396906 0
 4 2008         . 1
 4 2009 -.0548568 0
 4 2010 -.0505287 0
 4 2011 -.0278011 0
 4 2012 -.1094959 0
 4 2013 -.0561755 0
 4 2014 -.2681791 0
 5 2009 -.0214121 0
 5 2010 -.0298999 0
 5 2011 -.0174431 0
 5 2012  -.108873 0
 5 2013 -.0037315 1
 6 2008  -.088503 0
 6 2009 -.0663677 0
 6 2010 -.0702618 0
 6 2011 -.0697152 0
 6 2012 -.0035559 1
 6 2013 -.0106568 1
 6 2014 -.0086157 1
 7 2006 -.0415927 0
 7 2007 -.1197742 0
 7 2008  -.120332 0
 8 2007 -.0156878 0
 8 2008 -.0062815 1
 8 2009 -.0053927 1
 8 2010 -.0116363 1
 9 2007 -.0248356 0
 9 2008 -.0226686 0
10 2014 -.0220848 0
10 2015 -.0086376 1
10 2016 -.0080678 1
10 2017 -.0068192 1
11 2005 -.0069379 1
11 2006 -.0269457 0
11 2007 -.0194413 0
11 2008 -.0146663 0
11 2009 -.0347264 0
11 2010 -.0008378 1
11 2011 -.0041977 1
11 2012 -.0109522 1
11 2013 -.0109729 1
11 2014 -.0034999 1
11 2015 -.0161325 0
11 2016 -.0126282 1
11 2017 -.0055227 1
11 2018 -.0045366 1
12 2005   -.00056 1
12 2006 -.0164519 0
12 2007 -.0033264 1
12 2008 -.0156656 0
12 2009 -.0022345 1
12 2010 -.0030491 1
12 2011 -.0100019 1
12 2012 -.0004094 1
12 2013 -.0031059 1
12 2014  -.009291 1
12 2015 -.0051872 1
12 2016 -.0165904 0
12 2017 -.0101913 1
12 2018  -.011638 1
13 2010 -.0101051 1
13 2011 -.0080933 1
13 2012  -.021818 0
13 2013 -.0084147 1
13 2014 -.0149729 0
13 2015  -.005738 1
13 2016 -.0019629 1
13 2017 -.0235376 0
14 2007 -.0957858 0
14 2008 -.0553952 0
14 2009 -.0753054 0
14 2010 -.2311053 0
14 2011   -.20144 0
14 2012 -.0599314 0
14 2013 -.0075998 1
14 2014 -.0102946 1
14 2015 -.0442308 0
14 2016 -.1067018 0
14 2017 -.1399602 0
14 2018 -.0676559 0
15 2007 -.0070455 1
15 2008 -.0106885 1
15 2009 -.0152976 0
15 2010 -.0222663 0
15 2011 -.0146463 0
15 2012 -.0170992 0
end