DATA Step, Macro, Functions and more

how to create an unique composite index in the data step?

Reply
N/A
Posts: 0

how to create an unique composite index in the data step?

Hi, All!

I want create an unique composite index in the data step for limit dumplicate rows inserted.

The Logic SAS Code may like following:

data work.wolf(index=(id name /unique ));
infile datalines dlm="|";
length id 8. name $10. age 8.;
input id name age;
datalines;
1|forest|10
2|forest|11
2|forest|12
3|forest|13
2|forest|14
;
run;

In the rows in the work.wolf as following:
1|forest|10
2|forest|11
3|forest|13

My SAS version is:9.2
Super Contributor
Super Contributor
Posts: 3,174

Re: how to create an unique composite index in the data step?

Posted in reply to deleted_user
Suggest you start with the SAS documentation and the SAS support http://support.sas.com/ website (free) resources.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

data step programming composite index site:sas.com
Super Contributor
Super Contributor
Posts: 365

Re: how to create an unique composite index in the data step?

Posted in reply to deleted_user
Hello Wolf,

If I understood you correctly this could be a possible solution:

data work.wolf(/*index=(id name /unique )*/);
infile datalines dlm="|";
length id 8. name $10. age 8.;
input id name age;
datalines;
1|forest|10
2|forest|11
2|forest|12
3|forest|13
2|forest|14
;
run;
proc sort data=wolf nodupkey;
by id name;
run;
proc datasets library=work;
modify wolf;
index create idn=(id name);
run;

Sincerely,
SPR
Ask a Question
Discussion stats
  • 2 replies
  • 119 views
  • 0 likes
  • 3 in conversation