BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 754 views
  • 0 likes
  • 3 in conversation