• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / SAS / Change Length of Character Variable in SAS Dataset

Change Length of Character Variable in SAS Dataset

September 15, 2022 Leave a Comment

To change the length of a character variable in SAS, you can use the LENGTH statement before the SET statement in a data step.

data want;
    length name $30;
    set have;
run;

You can change the length of one or more character variables with the LENGTH statement.

data want;
    length name second_name third_name $30;
    set have;
run;

When working with character variables in your SAS datasets, the ability to easily be able to modify and change the properties of those variables is important.

One such case is if you want to change the length of a character variable in a SAS dataset.

To change the length of a character variable in SAS, you can use the LENGTH statement before the SET statement in a data step.

Below shows you a simple example of how you can change the length of a character variable in SAS.

data want;
    length name $30;
    set have;
run;

You can change the length of one or more character variables with the LENGTH statement.

If you want to change the length of multiple character variables, just list them before specifying the length.

Below shows you how to change the length of multiple variables in SAS.

data want;
    length name second_name third_name $30;
    set have;
run;

Hopefully this article has been useful for you to learn how to change the length of character variables in SAS.

Other Articles You'll Also Like:

  • 1.  SAS left() Function – Left Align Character Variables in Data Step
  • 2.  SAS intnx – Add or Subtract Time from Date Variables in SAS Data Step
  • 3.  SAS let – Create User-Defined Macro Variables in Your SAS Code
  • 4.  SAS Less Than or Equal to with LE or <=
  • 5.  Do Loop in SAS Macro Language
  • 6.  SAS call symput – Create Macro Variables in Data Step
  • 7.  SAS Lowercase – Make String Lowercase with SAS lowcase function
  • 8.  SAS mean() Function – Find Average Across Columns in Data Step
  • 9.  countw SAS – Count Number of Words in a String
  • 10.  SAS scan Function – Return nth Word from Character String

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy