BookmarkSubscribeRSS Feed
c4shiva
Calcite | Level 5

Hi All, 

 

Can  pls explain the below code. My doubt is 

 

1. var.sec_terc --> is this a table or column name?

 

2.from DET_CT var  --> What it is actually? If table, above one is column name is it?


proc sql;
create table CT_M. as select
var.sec_terc
,max (case when (var.mod_r in ('01') and var.CAL IN ('P') and FEC_COR_R BETWEEN intnx('month', "&PAR_FEC_H"d, -2, 'end') 
AND intnx('month', "&PAR_FEC_H"d, -4, 'begin') and var.edad_m_r>=0) then min(12,var.edad_m_r) else . end) as C_150

from DET_CT var 
where var.CALIDAD IN ('P' 'C' 'S' 'A')
and var.ESTADO_R not in ('7' '07' ' 7' '7 ' '70')
group by var.sec_terc;
quit;

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I really suggest you look up some SQL help as this is pretty basic.

https://www.w3schools.com/sql/

 

Point 2 first.  

from det_ct var

What this does is it tells the compiler to take data from dataset det_ct, which is by default in the work library as no library specified, and assign to this data the alias var.  Therefore to refer to any variables from this dataset I use the alias var.

 

Point 1.

var.sec_terc

This leads on from the above point, where an alias var has been created to refer to the det_ct dataset.  It is effectively saying the variable from det_ct which is referenced by alias var.

c4shiva
Calcite | Level 5
Thank you so much ... now am clear... Am a fresher just started to learn SAS from google. Thanks again for your link.. very helpful.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 603 views
  • 0 likes
  • 2 in conversation