Help using Base SAS procedures

Is it possible to assign a sort order to a 0 observation dataset?

Reply
N/A
Posts: 0

Is it possible to assign a sort order to a 0 observation dataset?

I am making 0 observation datasets from dataset specs in order to check the metadata for "correctness". (i.e. are CDISC names and labels used)

For completeness, I'd like to include the specified sort order, but have as yet not found a way to make that happen.

Any slick ideas for getting this info into the datasets so it ultimately is available in the dictionary tables?

Thanks for any ideas.
Frequent Contributor
Posts: 139

Re: Is it possible to assign a sort order to a 0 observation dataset?

Posted in reply to deleted_user
Diane,

Do you mean to find out the sort order of an existing table?

To do that go to the SAS dictionary tables (sashelp.vcolumn) and look at the field sortedby for the table that you want.

Do you mean to create a SAS table and then tell it what the sort order should be?

PROC DATASETS among other things lets you change the metadata of a dataset. Specifically for your case, you can tell SAS what the sort order is with out sorting the file.

Danger!!!!!
However, this may be quite dangerous for if you insert records not in the sort order sequence that you specify. Merges and other by group processing will not work. I would just sort the file after I updated it or index it.

But below is the example anyways.


proc sql;
create table One
(ID char(12),
x1 num,
x2 num,
x3 num);
quit;

proc datasets library=work nolist;
modify One (sortedby=x1 x2);
quit;

proc contents data=one;
run;


Good Luck
-Darryl
N/A
Posts: 0

Re: Is it possible to assign a sort order to a 0 observation dataset?

Posted in reply to deleted_user
"Do you mean to create a SAS table and then tell it what the sort order should be?"

This is the one. Worked great. Thanks!!! Since these are strictly for checking the accuracy of specifications, no records should ever be added, but I'll remember the warning just in case.
Ask a Question
Discussion stats
  • 2 replies
  • 103 views
  • 0 likes
  • 2 in conversation