Sorting Question

Reply
N/A
Posts: 1

Sorting Question

Hi Everyone,

I am an new SAS user so I'm still learning basics. I have a Dataset that contains a ton of info on Customer Claims on coils. Each coil has a product type. There are hundreds of coils and 7 product types. I need my output sorted by product type. The 7 product types need to be in a specific order. Where this would be a simple click and drag in Excel, I have no idea how to do it in SAS. Any suggestions would be greatly appreciated!!

Super User
Posts: 5,099

Re: Sorting Question

Stacy,

Have you already read your data into a SAS data set?  That would be a necessary first step.

Once your data is in a SAS data set, this step would sort it:

proc sort data=coil_data;

   by product_type;

run;

The resulting order would be alphabetical, according to the value of product_type.  If you wanted some other order, you would have to add a new variable to your data before sorting:

if product_type='A' then sorted_order=5;

else if product_type='B' then sorted_order=2;

...

else if product_type='G' then sorted_order=3;

Then you could sort the data by this new variable.

Those are the concepts to master ... good luck.

Ask a Question
Discussion stats
  • 1 reply
  • 129 views
  • 0 likes
  • 2 in conversation