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:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.