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,
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.
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.
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
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.
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.