call the information from the below statements

Discussion in 'SAS (Statistical Analysis Software)' started by raju Tadala, Apr 27, 2011.

  1. raju Tadala

    raju Tadala Guest

    HI,

    i want to write a code that should call the below datastep name dmg
    and by variable patient then data should be sorted .


    proc transpose data=dmg;
    var age;
    by patient;
    run;

    i hope u can understand my problem.while i am merging or transposing
    datasets it is throwing an error data is not sorted ,again i have to
    sort the datasets using by variable in transpose.
    so my idea is i want to write a macro it should call the information
    from the below statements and it should be sorted and next transpose
    steps should run.
     
    raju Tadala, Apr 27, 2011
    #1
    1. Advertisements

  2. raju Tadala

    Jill Guest

    Both proc transpose and data step's merge require you to sort the data
    first.
    Add this to your code before proc transpose (or merge):

    proc sort data=dmg; by patient; run;

    Hope I understood you correctly.
     
    Jill, Apr 27, 2011
    #2
    1. Advertisements

  3. raju Tadala

    RolandRB Guest

    I think he wants a method to automatially read ahead the sas code and
    automatically do a sort on the by variables if it needs to be done. I
    doubt this can be done. And even if it could be done it would not be
    very sensible.
     
    RolandRB, Apr 27, 2011
    #3
  4. raju Tadala

    Ya Guest

    If that's the case, you may still add the proc sort step, when the
    data is already sorted,
    SAS won't sort again.
     
    Ya, Apr 27, 2011
    #4
  5. raju Tadala

    Reeza Guest

    It sounds like you want SAS to recognize that if the data is not
    sorted the way it should be for a merge or proc transpose then it
    should sort and carry on with the requested procedure.
    SAS currently doesn't do this, an option to do it would be useful.

    However, if you're dealing with large data sets and have to sort 26
    gigabytes that process may take a lot longer than expected.

    There are methods for merge that don't require a sort, ie PROC SQL
    and for proc transpose you might be able to do it by writing a data
    step.

    The amount of time required to create these macros isn't worth the
    time it takes to type a proc sort in front of your data steps. Also if
    your data is already sorted, especially larger ones, attempting to
    sort again or even checking is a waste of resources.

    My 2cents.
     
    Reeza, Apr 27, 2011
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.