Exampler.org SAS PYTHON HTML
SAS Introduction
SAS Abs
SAS Anydigit
SAS ASC
SAS Case Stmnt.
SAS Ceiling
SAS Change type
SAS Char
SAS CMISS
SAS Coalesc
SAS Coalescec
SAS Concatenate
SAS Constant
SAS Create Table
SAS DateTime
SAS Day
SAS Find
SAS Floor
SAS HMS
SAS Holiday
SAS HOUR
SAS Import
SAS Informats
SAS Inobs
SAS Input Stmt.
SAS Int
SAS INTNX
SAS Length
SAS Libname
SAS Loops
SAS Minute
SAS Month
SAS MDY
SAS NMISS
SAS Notdigit
SAS Lowercase
SAS Outobs
SAS Put Stmt.
SAS Rename
SAS Round
SAS Scan
SAS Substr
SAS Sum
SAS STNAME
SAS STNAMEL
SAS Time
SAS Trunc
SAS Uppercase
SAS Week
SAS Year
SAS Financial Functions
SAS Compound

SAS - Length

What is it?

Length Example:


 Length Example:



libname ABCDEFGH postgres server="Server_Address.com" port=5432 user=kevin password="P@ssW0rd" database=DBName schema=SchemaName;


Data work.my_data_file;

    Result 1 = length(' hello ');
    Result 2 = lengthc(' hello ');
    Result 3 = lengthm(' hello ');
    Result 4 = lengthn(' hello ');
run;

proc
  print data=my_data_file;
run;





What's happening in the script above?

  • The script is connecting to the postgres database/datasource
  • Data step is creating the work.my_data_file temporary dataset
  • 4 Length functions; results can be found below.


Length Examples:

Round Input Output Description
Length hello 6 Returns the length of a string; trailing blanks excluded; returns 1 for blanks.
Lengthc hello 7 Returns the length of a string; trailing blanks included.
Lengthm hello 7 Returns the number of bites
Lengthn hello 6 Returns the length of a string; trailing blanks excluded.

Connect via LinkedIn

Kevin Regan

Have an article, idea, found a typo, want to contribute? Shoot me an email Here


Below are links to some Udemy Data Science Courses. I've been using Udemy for a number of years now, and I've found their courses super helpful, maybe you will also.