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.
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.
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.
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!
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.);
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.