nick_dataFE
nick_dataFE

Reputation: 57

Generating new Variable in SAS results in ERROR 180-322

I am very new to SAS, which is why this question has probably a quite easy answer. I use the SAS university edition.

I have dataset containing socio-structural data in 31 variables and 1000000 observations. The data is stored in a Stata .dta file, which is why I used the following code to import in into SAS:

LIBNAME IN '/folders/myfolders/fake_data';

proc import out= fake_2017 datafile = "/folders/myfolders/fake_data/mz_2017.dta" replace;
run;

Now, I want to create new variables. At first, a year variable that takes the value 2017 for all observations. After, I have several other variables that I want to generate from the 31 existing variables. However, running my code I get the same error message for all my steps:

year = 2017;
run;

ERROR 180-322: Statement is not valid or it is used out of proper order.

I found many things online but nothing that'd help me. What am I doing wrong/forgetting? For me, the code looks like in all the SAS tutorial videos that I have already watched.

Upvotes: 2

Views: 121

Answers (1)

Tom
Tom

Reputation: 51621

You cannot have an assignment statement outside of a data step. You used a PROC IMPORT step to create a dataset named fake_2017. So now you need to run a data step to make a new dataset where you can create your new variable. Let's call the new dataset fixed_2017.

data fixed_2017;
  set fake_2017;
  year=2017;
run;

Upvotes: 1

Related Questions