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:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.