BookmarkSubscribeRSS Feed
Smitha9
Fluorite | Level 6

Hi,

I have a dataset which includes the variable names:

A B C D

the above dataset need to format once in a week.

Everyweek I have to check the order of the variables A B C D

If D comes first or the order changes I need to flag it. The order must be A B C D order.

Can I know the code for this.

 

thank you in advance.

-Smitha

8 REPLIES 8
Smitha9
Fluorite | Level 6

Hi,

I have a variables list

A B C D

Everytime when I get the data and formatted. I need to check the order is correct. If D comes first then I need to flag it.

The code needs to check the order of the variables "A B C D"

how can I do that?

thank you in advance.

-Smitha

PeterClemmensen
Tourmaline | Level 20

Are A, B, C and D your variable names or your varaible values?

Smitha9
Fluorite | Level 6
Variable names.
RichardDeVen
Barite | Level 11
Can you explain what you are doing and why the variable order matters. Does the data set contain other variables ? If so, where should A,B,C,D be in relation to them ?
Smitha9
Fluorite | Level 6
Hi,
this is an example I gave.
My dataset has around 4 variables.
Lets say if we have A B C D. This dataset gets new values everyweek and gets formatted everyweek. I need to check the order of the variable names are correct and if there is a problem with the order of the variable names I need to flag it.

thanks
ballardw
Super User

@Smitha9 wrote:

Hi,

I have a dataset which includes the variable names:

A B C D

the above dataset need to format once in a week.

Everyweek I have to check the order of the variables A B C D

If D comes first or the order changes I need to flag it. The order must be A B C D order.

Can I know the code for this.

 

thank you in advance.

-Smitha


SAS data sets do not care about the order of variables generally. So why is this an issue?

 

And if your data source is changing the order that is the place to address things, before it gets to you.

 

Proc contents will tell you the column number of a variable.

Ksharp
Super User
proc contents data=sashelp.class varnum out=x noprint;
run;

Check Variable Name and Variable Number in dataset X .

Or try Dictionary.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 8 replies
  • 1154 views
  • 0 likes
  • 6 in conversation