×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Specifying Variable Order in the Output table???

Specifying Variable Order in the Output table???

Specifying Variable Order in the Output table???

(OP)
How do you create a SAS table using proc report?  I want to create a table specifying the order of variables.  I was told this is the best way to do it.  Is this true?  I also tried "Drop" and "Attrib" option but couldn't get it to work.  What's the fast and efficient way to do it?


proc report data=practice.Xmas_in_out_checklist_2001;
column Item_Num Category Description;
run;

Thanks,
RookieDBO

RE: Specifying Variable Order in the Output table???

To create a SAS dataset with variables in a certain order, I find it easier to do it using the retain statement in the data step.... eg:

data y; set practice.xmas_in_out_checklist_2001;
  retain item_num category description;
run;


If you do a PROC PRINT on dataset Y you should see the variables in the order you specify.

You can also do it in proc report but it would involve more codes---- not worth it unless you are creating a report at the same time.

RE: Specifying Variable Order in the Output table???

(OP)
Hi.  That didn't quite work.  It created an identical table.
Anymore solutions?

Thanks,
RookieDBO

RE: Specifying Variable Order in the Output table???

(OP)
Aren't there any SAS programmer in here???  Why doesn't anybody uses SAS? And why is it so hard to find SAS help?  Does anyone know a good SAS forum?

RE: Specifying Variable Order in the Output table???

Without having access to SAS at this very moment, I cannot check out why my previous solution didn't work (sorry about that).

Another solution is to try PROC SQL and specify your variable order in there.

PROC SQL;
CREATE TABLE Y AS
SELECT item_num, category, description
FROM practice.xmas_in_out_checklist_2001;

There is a SAS-L email discussion list which you can subscribe to (and I believe a web discussion forum is now available also)--- I don't have the URL but you may want to just do a search of SAS-L on Yahoo or Google?

RE: Specifying Variable Order in the Output table???

The example was flawed......

Instead of this:
data y; set practice.xmas_in_out_checklist_2001;
  retain item_num category description;
run;

Do this:
data y; retain item_num category description;
  set practice.xmas_in_out_checklist_2001;
run;

RE: Specifying Variable Order in the Output table???

On some of the other points, I'm 99% certain that DROP= and ATTRIB= are not options associated with PROC REPORT - this probably does not help!

What did the log say when you tried the code you specified?

I'm not sure about x1bobx2's example - retain is used to create static variables (also, putting two statements on one line is not recommended in my book). The keep option should have been used within the data line rather than using a retain statement. In any event I don't think it's good practice to create extra datasets when the existing one will do for the purposes of PROC REPORT.

The column statement you've quoted should work. If you want to set the attributes of the data columns you need a further statement in teh PROC step - DEFINE.

Hope this helps.

SuperBry!

RE: Specifying Variable Order in the Output table???

x1bobx2's works.

you can also use format or informat instead of retain. thing is, you have to put the statement before the set statement. ohterwise the variables are created by the set and you can not take influence with any following statement on the order of the variables.
when you use retain/format/informat before the set, the variables are created by that statement and thereby in that order specified. the order of the statement is the trick, not the statement.

and by the way. you can specify as many statements in one row as you want to. that the sense of the semicolon. it seperates the statements from each other. if it is not recommended that might be because of stylistic/readability reasons not because your code might not work.

DROP= and ATTRIB= are no statements. statements are associated with procedures (DROP ... and ATTRIB ... would be statements). DROP= and ATTRIB= are data set options. you specify them in parantheses after the data set name. you can use them anywhere a set is named.

hope that helps
axel

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close