BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
baumannnick97
Calcite | Level 5

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.

Thank you for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

A command such as year=2017; must be in a DATA step.

 

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

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

A command such as year=2017; must be in a DATA step.

 

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

 

--
Paige Miller
User_Help
Obsidian | Level 7

 

try Tools -- Options -- Graph -- check "Suppress graph option statements in generated code".

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 767 views
  • 0 likes
  • 3 in conversation