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

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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