BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Erkika
Calcite | Level 5

Hello

 

I'm trying to understand why certain things are considered options- and are defined when a procedure is invoked- and why others are defined in separate statements;

 

For example:

 

proc means data=input_data n mean sum;

     var analysis_variable;

     class category_variable;

run;

 

Why are the specific descriptive statistics in the "proc means" statement, whereas the analysis variable and classification variable are each their own statement?

 

I remember how to write code better when I understand why things are written in a certain way, so I'm hoping some one can help me understand this difference!

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

@Erkika - welcome to the rabbit hole of a 40+ year old programming language!

 

I'll let others answer with their own experience and mnemonics that help them, but I'll say this.  Many procedures have statements that are common and behave in the same expected way.  These statements include VAR, BY, CLASS, FREQ, WEIGHT, and a few others.

 

The PROC statement itself (like "PROC MEANS ....") is one place where the SAS developer can hang some of the options that are specific to this procedure.  Another place they can do that is via a proc-specific statement (a statement name, with arguments and potentially its own options, terminated by a semicolon).

 

If I'm being honest, not all SAS procs are consistent with what becomes an option vs a statement.  More recent procedures are consistent amongst themselves, but lots of older procs (like MEANS) are what they've always been, and cannot be changed because bazillions of production SAS jobs rely on them as they are.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

3 REPLIES 3
ChrisHemedinger
Community Manager

@Erkika - welcome to the rabbit hole of a 40+ year old programming language!

 

I'll let others answer with their own experience and mnemonics that help them, but I'll say this.  Many procedures have statements that are common and behave in the same expected way.  These statements include VAR, BY, CLASS, FREQ, WEIGHT, and a few others.

 

The PROC statement itself (like "PROC MEANS ....") is one place where the SAS developer can hang some of the options that are specific to this procedure.  Another place they can do that is via a proc-specific statement (a statement name, with arguments and potentially its own options, terminated by a semicolon).

 

If I'm being honest, not all SAS procs are consistent with what becomes an option vs a statement.  More recent procedures are consistent amongst themselves, but lots of older procs (like MEANS) are what they've always been, and cannot be changed because bazillions of production SAS jobs rely on them as they are.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
WarrenKuhfeld
Rhodochrosite | Level 12

Chris is right.  The one thing I will add is we can't say proc whatever and then have a mix of options and variable names in the same statement.  Which is which?  So var ists were put on separate statements.  When a variable list ends and options begin (e.g. after the independent variables in a MODEL statement), a slash is used to indicate the separation.  Now things were pretty much that simple in the 70s and 80s.  Syntax has gotten much more complex since then, but that is the reason why variable lists were not put on the proc statement.

Ron_MacroMaven
Lapis Lazuli | Level 10

\begin{Op.Ed}

After 30 years of programming I am returning to what I learned in university:

it's either data structure (compiled) or algorithm (executed).

 

I like @ChrisHemedinger's notes that many statements are available as subroutines to a wide variety of procedures.

 

I am writing a paper for SESUG.2017 where I highlight the differences between local and global variables

and making the point that we don't think of the several global statements

-- filename, libname, options, running text (titles, footnotes) --

as making entries in the global symbol table.

 

I make a point in my Style Guide to differentiate between the compiler directives

--- attribute, (length, format, label), array, drop/keep, retain, etc. ---

and the executed statements

-- assignment , do, if, link.

 

Once I began to read and write my programs in two passes: data structure, then algorithm,

my debugging and testing time went down my an order of magnitude.

 

\end{Op.Ed}

 

Ron Fehd which? ever! maven

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3375 views
  • 8 likes
  • 4 in conversation