Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for multiple numbers

Status
Not open for further replies.

wphupkes

Technical User
Jul 1, 2008
22
NL
Hi all!

Should be a simple task, but I don't get the code right...

I want to know (and FLAG) if a record contains a 1 time number or if there are other records with the same number. So I've got a dataset like:

1 text
2 text
2 text
3 text
4 text
4 text
4 text

I want to create a 'FLAG', so I know a number appears more than once in the dataset. The outcome should be something like:

1 text 0
2 text 1
2 text 1
3 text 0
4 text 1
4 text 1
4 text 1

Can anyone help me with this? Thanks!!
 
Hi duckman75,

try with first/last checks - make sure your input is sorted, else it'll fail.

[tt]/*-- flag unique (0) / multi (1) lineNo */
data sample;
set sample;
by lineNo;
multiFlag = not (first.lineNo and last.lineNo);
run;[/tt]

Hope that helps.

Cheers,
Matthias
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top