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.);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.