DATA Step, Macro, Functions and more

What is the meaning of underbar(_)?

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

What is the meaning of underbar(_)?

I am trying to understand the following code and had a trouble finding the meaning for both _link and _temp. 

 

%if %lowcase(&id)=cusip %then %do;
  proc sql;
   create view  _link
   as select permno, ncusip,
   min(namedt) as fdate format=date9., max(nameendt) as ldate format=date9.
   from crsp.dsenames																	
   group by permno, ncusip;
     
   create table _temp
   as select distinct b.permno, a.*
   from &inset a left join _link b
   on a.cusip=b.ncusip and b.fdate<=a.&evtdate<=b.ldate
   order by b.permno, a.&evtdate; 
  quit;%end;
  %else %do;
  /*pre-sort the input dataset in case it is not sorted yet*/
  proc sort data=&inset out=_temp;
   by permno &evtdate;  /* error correction. CHANGE HERE */
  run;
  %end;

I looked for _link in multiple sources(language reference, step by step programming with base SAS, and google), but I could not find information about it. I would appreciate if you can share where to look for the definition and syntax of _link and _temp. 

 

Thank you very much. 


Accepted Solutions
Solution
‎10-26-2016 06:11 PM
Super User
Posts: 10,483

Re: What is the meaning of underbar(_)?

Basically in this case they are the names of the resulting data view or data set. SAS names for data sets start with a letter or _ character and have a maximum lenght of 32 characters consisting of letter, digit or _ character.

 

_link may well have been named "lookup" "Linkset" "fred". Thats just what the coder chose as the name indicates it may be used in some sort of linking operation.

_temp would indicate a data set the coder considers to be temporary but different then a possibly existing set named "temp"

View solution in original post


All Replies
Solution
‎10-26-2016 06:11 PM
Super User
Posts: 10,483

Re: What is the meaning of underbar(_)?

Basically in this case they are the names of the resulting data view or data set. SAS names for data sets start with a letter or _ character and have a maximum lenght of 32 characters consisting of letter, digit or _ character.

 

_link may well have been named "lookup" "Linkset" "fred". Thats just what the coder chose as the name indicates it may be used in some sort of linking operation.

_temp would indicate a data set the coder considers to be temporary but different then a possibly existing set named "temp"

Contributor
Posts: 22

Re: What is the meaning of underbar(_)?

Haha, usually I get ashamed when I ask a question. But for this one, I feel especially ashamed even after getting the answer. Since we have link statement, I thought _link has some special function! 

 

Thank you for your comment and I will never forget that name in SAS can start with _.

 

 

PROC Star
Posts: 1,561

Re: What is the meaning of underbar(_)?

[ Edited ]

That's why formatting one's code properly is so important: it boosts legibility and reduces chances of errors.

 

You wouldn't have asked the question if the programmer had taken a few seconds to write:

 

 create view _LINK
   as select PERMNO
           , NCUSIP
           , min(NAMEDT)   as FDATE format=date9.
           , max(NAMEENDT) as LDATE format=date9.
   from CRSP.DSENAMES	
   group by PERMNO, NCUSIP

 

Just using vertical alignment and lower/uppercase for sas language/user names makes the code so much easier to develop and maintain.

 

 

 

 

Contributor
Posts: 22

Re: What is the meaning of underbar(_)?

Thank you ChrisNZ!

 

That is so true. I recently started learning SAS, and your advice can definitely save hours of debugging and coding for me. I will definitely keep code as you have shown me Smiley Happy

Senior User _pj
Senior User
Posts: 1

Re: What is the meaning of underbar(_)?

Also, 'underbar' is the swedish word for 'Wonderful' Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 606 views
  • 9 likes
  • 4 in conversation