Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Sorting and renaming during import stage

Accepted Solution Solved
Reply
Regular Contributor
Posts: 218
Accepted Solution

Sorting and renaming during import stage

Hi All,

Can anyone tell me if I can use 'sort', 'rename' and 'where' command during the data import stage (in another word during data step)?

I want to:

sort them by Emp_ID; and

rename as Name=Student_name; and

import observations where Student_name<>'';

Here is my initial code that I wrote without any of the above condition.


proc import datafile="E:\data_nonsort.xlsx"

dbms=xlsx replace

out=data_sort (keep = Emp_ID Name);

sheet='test';

run;

Thanks and I much appreciate your help,


Accepted Solutions
Solution
‎06-17-2015 11:40 AM
Frequent Contributor
Posts: 130

Re: Sorting and renaming during import stage

You can rename your variable Name by modifying your import procedure like so:

proc import datafile="E:\data_nonsort.xlsx"

dbms=xlsx replace

out=data_sort (rename=(Name=Student_name) keep=Emp_ID Name);

sheet='test';

run;

I believe filtering and sorting will have to be done in a separate sort procedure after you import the file into a SAS data set.

Hope that helps.

View solution in original post


All Replies
Solution
‎06-17-2015 11:40 AM
Frequent Contributor
Posts: 130

Re: Sorting and renaming during import stage

You can rename your variable Name by modifying your import procedure like so:

proc import datafile="E:\data_nonsort.xlsx"

dbms=xlsx replace

out=data_sort (rename=(Name=Student_name) keep=Emp_ID Name);

sheet='test';

run;

I believe filtering and sorting will have to be done in a separate sort procedure after you import the file into a SAS data set.

Hope that helps.

Super User
Posts: 10,023

Re: Sorting and renaming during import stage

Try to use index= option to sort dataset.

proc import datafile="E:\data_nonsort.xlsx"

dbms=xlsx replace

out=data_sort (rename=(Name=Student_name) keep=Emp_ID Name index=(name)  where=(age gt 12));

sheet='test';

run;

Xia Keshan

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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