BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hi. I am using PROC SORT Nodupkey to remove duplicate data. The thing is, no matter how i put (KEEP=) statement, the output column is only displaying as per my BY statement.

 

For example:

proc sort data=ppu_sum2
out=ppu_sum(keep=substationname substationcode voltagetype equipmentname feedertype substationtype datetime) nodupkey;
by substationname substationcode  substationtype datetime;
run;

 

 

How can i make it output according to the out(KEEP=) statement?

4 REPLIES 4
novinosrin
Tourmaline | Level 20

do you mean the order of the columns from left to right?

 

data want;
retain substationname substationcode voltagetype equipmentname feedertype substationtype datetime;
set ppusum;
run;

 

Tom
Super User Tom
Super User

I would be very surprised if the KEEP statement is not honored.  Are you sure your PROC SORT step ran?

 

If you are really concerned then move the KEEP= dataset option to the input dataset instead of the output dataset.  Why bother keeping the other variables around during the sorting?

 

Note that you are keeping more variables than you are using in the BY statement.  So SAS will just keep the values of the extra variables from the one observation in selects for that BY group.

Kurt_Bremser
Super User

Maxim 2: Read the Log

If that does not provide a clue, post it here.

 

Are you sure that ppu_sum2 contains all the variables you have in the keep= option?

ballardw
Super User

"Never works" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 10878 views
  • 0 likes
  • 5 in conversation