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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 934 views
  • 0 likes
  • 2 in conversation