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

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 1024 views
  • 4 likes
  • 4 in conversation