Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does SAS order variables in PDV.

Status
Not open for further replies.

Asender

Programmer
Jun 4, 2003
31
GB
Hi there.

This is more a curiosity that a problem.

Most experienced SAS programmers will be familiar with the concept of the Program Data Vector (PDV) and how SAS populates it with variables as a SAS Data Step is compiled.

This little excerpt from a SUGI paper sums up how I understand it:

"Variables are added to the PDV in the order seen by
the compiler during parsing and interpretation of
source statements."

If so can anyone explain to me what is going on here:

data WORK.RESULTS;
first = second + third;
run;

As I understand it variables should appear in the output data set ordered 'first', 'second' and 'third'.

Instead, they appear ordered 'first', 'third' and 'second'.

What's going on?

Cheers,


Chris...
 
Real interesting. I was going to postulate that perhaps SAS reads right to left in an equation, but if you add more vars there doesn't seem to be a mixup of the order. Only in the first two positions.

Well I'm stumped! I suppose it has to do with the way the compiler is written.
 
Hi Klaz.

I'm glad I'm not the only one stumped.

I think the order of evaluation must have something to do with it.

Check this out:

first = second + third + fourth; gives (first, third, second and fourth).

however,

first = second + (third + fourth); gives (first, fourth, third and second).

It does dent my understanding of tokenized words during compilation.

Thanks for your reply Klaz.

Regards,



Chris...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top