Hello, I'm new to SAS and after doing a lot of searching, I can't seem to get some simple data operations to work. Given a dataset, I want to replace certain data entries systematically. My document contains several unwanted entries with the string "DQ" and I want to replace them in the data step with missing values ".". The problem is, I get errors and I suspect it has to do because the "DQ" entries are given for both numerical and categorical variables. I have tried three different approaches, and all of them have yielded errors that my data is invalid still. Note: when I used the 'replace all' function in notepad and ran the data, I had no "invalid data" problems. To show my approaches, let "categorical" and "numerical" be my variables. Approach #1: numerical = .; replace all var{numerical} where(numerical = "DQ); categorical = "."; replace all var{categorical} where(categorical = "DQ"); Approach #2: if numerical = "DQ" then numerical = .; if categorical = "DQ" then categorical = "."; Approach #3: numerical = tranwrd(numerical, "DQ", .); categorical=tranwrd(categorical, "DQ", "."); Is there something fundamentally wrong with my approach? Even though I distinguish between "." and . without quotations - I have not been able to successfully run the data. I run SAS remotely, so I cannot view the data from within the program; the log simply informs me of the errors. Thanks in advance.
... View more