BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cosmid
Lapis Lazuli | Level 10

It seems, in a way, that the ID statement just replaces the NOOBS option.

 

proc print data=sample noobs;

  var IDNUM LastName;

 

proc print data=sample;

  ID IDNUM;

  var LastName;

run;

 

Or it can uses more than 1 variable to be the OBS column. I guess my question is when should I use ID instead of NOOBS?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You might also try:

Proc sort data=sample;
   by idnum;
run;

proc print data=sample;
  by idnum;
  ID IDNUM;
  var LastName;

run;

which will create a somewhat different appearance for the by group output than a simple by statement. The BY variable then appears as a row spanning value in the first column of the output for each BY value instead of having the "BYVAR=Value" appear before a table. Which can significantly reduce the number of vertical lines in the output, especially with 2 or more by variables.

 

ID behaves differently in many of the procedures that have the option so it is worth investigating when offered as an option. For instance it is possible to get the value of a variable associated with the 3 largest values of another in Proc Means/ Summary using ID plus some additional code.

View solution in original post

2 REPLIES 2
ballardw
Super User

You might also try:

Proc sort data=sample;
   by idnum;
run;

proc print data=sample;
  by idnum;
  ID IDNUM;
  var LastName;

run;

which will create a somewhat different appearance for the by group output than a simple by statement. The BY variable then appears as a row spanning value in the first column of the output for each BY value instead of having the "BYVAR=Value" appear before a table. Which can significantly reduce the number of vertical lines in the output, especially with 2 or more by variables.

 

ID behaves differently in many of the procedures that have the option so it is worth investigating when offered as an option. For instance it is possible to get the value of a variable associated with the 3 largest values of another in Proc Means/ Summary using ID plus some additional code.

cosmid
Lapis Lazuli | Level 10

Thanks again ballardw!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1024 views
  • 1 like
  • 2 in conversation