BookmarkSubscribeRSS Feed
Aman4SAS
Obsidian | Level 7

i have code :

 

data test;
input name $ age;
datalines;
a 1
a 2
a 3
A 1
a 4
A 3
A 2
;
run;
proc sort data=test nodupkey ;
by name; run;
proc print; run;

 

output is : A 1

                a  1

desire output is : a 1 (only)

 

is there any possibility to ignore case and select only first unique record.(without any kind of manipulation in data and using only proc sort)

 

Thanks in advance

 

2 REPLIES 2
ballardw
Super User

I don't think what you are attempting is possible with Proc Sort. It may be possible with proc sql however as you can upcase as needed:

 

You will either have to take a pass through a data step to UPCASE the variable(s) or add upcased variables.

 

Proc sql may give a similar result but does not have an actual concept of "first" so requires more code and likely data manipulation to maintain order.

data_null__
Jade | Level 19

 

data test;
input name $ age;
datalines;
a 1
a 2
a 3
A 1
a 4
A 3
A 2
;
run;
proc print;
   run;
proc summary nway data=test;
   format name $upcase.;
   class name;
   output out=nodupkey(drop=_type_ _freq_) idgroup(out(age--age)=);
   run;
proc print;
   format _all_;
   run;

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1829 views
  • 1 like
  • 3 in conversation