DATA Step, Macro, Functions and more

[SAS Macro] Will the macro change data's order

Reply
New Contributor
Posts: 4

[SAS Macro] Will the macro change data's order

Under Enterprise Guide 7.11 (7.100.1.2711) 64 bit, with WIndows 7 SP1.

 

I'm using the following sas macro:

 

%macro a(factor)

data input;

informat &factor._C best12.;

set input;

&factor_C=&factor;

run;

 

proc univariate data=input;

var &factor._C;

histogram &factor._C/normal(noprint) cbarline=grey;

run;

%mend;

 

It worked properly, but in the log, it returns me the error with the wrong column (compared to the original dataset input).

 

Ex: 

 

the observation's column was 257 (which has the issue), but the log of the macro returns my column 27 (which doesn't have an issue).

 

So, why does this macro change the order of my observations? Or does the macro change the order in general?

 

Thank you.

Super User
Posts: 7,863

Re: [SAS Macro] Will the macro change data's order

[ Edited ]

You are inconsistent in your question.

Do ask about the order of the columns, or the order of the observations?

 

Creating a new variable in a statement after the set statement will have this new column appear last within the observations, naming it before the set statement will put it first in the PDV and therefore in the output dataset.

 

A simple data step like yours will not change the order of observations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 4

Re: [SAS Macro] Will the macro change data's order

Posted in reply to KurtBremser

Sorry about the messed up, I'm always a little bit messed up with the rows/columns with the observations/factors.

 

And yes, I'm asking about the rows/observations.

 

I was wondering if this is because of the default ASC/DSC options with the new factors created in the macro?

 

Will this changed the order of my observations?(Since I added one new factors for all observations)

 

Thank you.

 

Jin

Super User
Posts: 7,863

Re: [SAS Macro] Will the macro change data's order

So, the question is, which ERROR are you getting?

And can you supply some test data (in a data step) so we can reproduce the behaviour?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 246 views
  • 0 likes
  • 2 in conversation