This works :
data xy;
input a b ;
z=a/b;
datalines ;
123 123
123 456
123 234
;
run;
but this does not :
data xy;
input a b ;
datalines ;
123 123
123 456
123 234
;
z=a/b;
run;
Can someone tell me why ? What's going on in the back-end ?
You cannot calculate a new variable after the data step has already been compiled and run.
What is confusing you is the spurious RUN: statement in your first example. That is NOT part of the data step.
Another reason to not add that spurious RUN; statement after the end of a data step that is reading in-line data when posting example code. Besides wasting a line in your program file It will confuse novice programmers.
From the documentation of the DATALINES Statement:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.