DATA Step, Macro, Functions and more

how to keep only the last column in the dataset

Reply
Occasional Contributor
Posts: 18

how to keep only the last column in the dataset

is there a shortcut to keep only the last column in the dataset?

for instance, keep last_column

Thanks,
Respected Advisor
Posts: 3,777

Re: how to keep only the last column in the dataset

If we assume that means the variable with the largest value of VARNUM then...

[pre]
42 proc sql;
43 select name into :lastName separated by ' '
44 from dictionary.columns
45 where libname='SASHELP' and memname='CLASS'
46 having varnum eq max(varnum)
47 ;
NOTE: The query requires remerging summary statistics back with the original data.
48 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds


49 run;
50 %put NOTE: LastName=&lastname;
NOTE: LastName=Weight
[/pre]

Use LASTNAME in a KEEP data set opion.
Ask a Question
Discussion stats
  • 1 reply
  • 616 views
  • 0 likes
  • 2 in conversation