BookmarkSubscribeRSS Feed
RuthE
Calcite | Level 5
 
3 REPLIES 3
ballardw
Super User

Length only lets you set one characteristic, the length. Attrib will let you set other properties like Informat, Format and Label as well as the length.

andreas_lds
Jade | Level 19

@RuthE wrote:

Hi all,

 

What is the difference between using ATTRIB statement and LENGTH statement when creating a new variable from existing variable?

 

Ruth 


Hello Ruth,

 

not sure what you mean with "creating a new variable from existing variable"?

lsandell
Obsidian | Level 7

The LEGNTH Statement (before the SET) allows you to define the length of some/all of the variables, and will permanently reset the length in your PDV and data set Iif you rearrange the variables in this LENGTH statement, it will also re-order your variables!). If you put the LENGTH statement after the set statement, it will not change the length in the PDV. 

 

The ATTRIB ("attributes") assigns many items to each variable assigned, such as Format, informat, length, Label, and transcode(Y/N). 

Here are links to helpful SAS documentation: Attrib Statement

Length Statement

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 574 views
  • 4 likes
  • 4 in conversation