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

Hi all, i have one variable name 'empsal' in middle of dataset (have around 9000 variable and 'empsal' is there in between) and i wants to bring it as second or first variable/column,- how can i do that?

plz help

thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Just add an ATTRIB statement before you read your dataset to make it first:

data new;

  attrib empsal length = 8;

  set old;

run;

If you want it second then add the variable you want first before empsal in the ATTRIB statement.

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Just add an ATTRIB statement before you read your dataset to make it first:

data new;

  attrib empsal length = 8;

  set old;

run;

If you want it second then add the variable you want first before empsal in the ATTRIB statement.

sas_9
Obsidian | Level 7

worked prefectly - Thanks SASKIWI.

one quick q, i have 'empsal' variable as employee name and salary,

e,g;

empsal

harstein1 150000

lawson2 120000

kumar3 50000

i want to keep salary only (150000, 120000, 50000) and remove (harstein1, lawson2, kumar3).

result would be;

empsal

150000

120000

50000

can you plz tell me how code should look like?

Thanks!

SASKiwi
PROC Star

If it's consistently always two words then you could do it this way:

empsal = scan(empsal,2);

However wouldn't it be better to store empsal as a number:

empsal_num = input(scan(empsal,2), best12.);

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1369 views
  • 0 likes
  • 2 in conversation