How do you use a field in SAS in proc sql?

If there is a data step:

data myRegions; set myRegions; ext_price = price * qty; mix = weighted_calc * ext_price; run; 

I want to do this in SQL, because I want to use some groups and subqueries, but can I do the price * qty operation every time I want to use this value ?!

+4
source share
1 answer

You can use the calculated from the documents:

CALCULATED allows you to use the results of an expression in the same SELECT or in a WHERE clause. It is valid only when used; refer to the columns that are evaluated in the immediate query expression.

Here is an example:

 proc sql; create table myRegions as Select a.*, (price * qty) as ext_price , (weighted_calc * calculated ext_price ) as mix from myRegions; quit; 
+4
source

Source: https://habr.com/ru/post/1485920/


All Articles