I'm importing a data set in Stata format using PROC IMPORT, but I'd like to use IF statements to create a few new variables as well. However, simply using code like this returns an error of "ERROR 180-322: Statement is not valid or it is used out of proper order." :
PROC IMPORT
DATAFILE = "myfile.dta"
DBMS = DTA
OUT = mydata
REPLACE;
IF close < 10 THEN val = "low";
ELSE val = "high";
RUN;
I don't see any code for a data step generated in my log file either, even if I use ODS TRACE ON. Is there another way to use IF statements here?
UPDATE: If I add a DATA step after the PROC IMPORT, as shown:
PROC IMPORT
DATAFILE = "myfile.dta"
DBMS = DTA
OUT = mydata
REPLACE;
RUN;
DATA mydata;
IF close < 10 THEN val = "low";
ELSE val = "high";
RUN;
PROC PRINT DATA=mydata;
RUN;
This only prints out an empty table like this:
close | val
| high
and inspecting the dataset shows that it doesn't contain any of the original data.