BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mlogan
Lapis Lazuli | Level 10

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,

1 ACCEPTED SOLUTION

Accepted Solutions
dcruik
Lapis Lazuli | Level 10

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

2 REPLIES 2
dcruik
Lapis Lazuli | Level 10

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.

Ksharp
Super User

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

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