Help using Base SAS procedures

loop with substr function

Not applicable
Posts: 0

loop with substr function


I am trying to create a dataset from an existing dataset.

The current dataset has a variable called id_code. The id_code is a string of length 10 characters. I need to extract the 2 left most characters and based on whether it is a 01 assign "temp" and if 02 assign "non-temp".

I have to repeat this process till the end of the dataset that has around 350 observations.

Could anyone help me with the code for this.

Super Contributor
Super Contributor
Posts: 3,176

Re: loop with substr function

Posted in reply to deleted_user
This is basic DATA step IF THEN ; logic.

Have a look at the SAS-hosted DOC and supplemental references on their SAS.COM support website - links revealed with search below. Then come back to the forum again with code challenges/issues -- suggest using the SAS diagnostic code below to reveal much info:


Scott Barry
SBBWorks, Inc.

Recommended Google advanced search arguments, this topic/post:

data step programming introduction

data step assign sas variable
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation