BookmarkSubscribeRSS Feed
Alankar
Fluorite | Level 6
Hi I've data like following.
custnbr mob bal
A 0 1
A 1 1
A 2 1
A 3 1
A 4 0
A 5 0
A 6 0
A 7 1
A 8 0
B 0 0
B 1 0
B 2 0
B 3 0
B 4 1
B 5 1
B 6 1
B 7 0

i need result like following.

A 0 1
A 1 1
A 2 1
A 3 1
A 4 1
A 5 1
A 6 1
A 7 1
A 8 1
B 0 0
B 1 0
B 2 0
B 3 0
B 4 1
B 5 1
B 6 1
B 7 1

basically the value when the record starts Bal = 1 then the same value should carry till end for the same customer.

Thanks in advance.
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
In a DATA step and using your SORTed file, you can use a temporary SAS variable (look up the RETAIN stmt) to test-for and capture the IF FIRST.CUSTNBR condition, and then assign the variable BAL to whatever is desired.

Scott Barry
SBBWorks, Inc.

DATA Step Processing
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001281588.htm

BY-Group Processing in the DATA Step (FIRST. is discussed here):
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001283274.htm

Understanding the SAS® DATA Step and the Program Data Vector
Steven First, Systems Seminar Consultants, Madison, WI
http://support.sas.com/resources/papers/proceedings09/136-2009.pdf

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1790 views
  • 0 likes
  • 2 in conversation