BookmarkSubscribeRSS Feed
Bal23
Lapis Lazuli | Level 10
proc sql;
	create table ac as
	select *
	from ab as a left join h1(drop=  i) as b
	on a.id=b.id2
	where hb=1;
data vital(drop=i);
length vstestcd $ 10 vsstresu $ 20;
retain vstestcd "WEIGHT" vsstresu "KG";
do usubjid=1001 to 6000;
do i= 1 to 10 ;
vsstresn = floor(74.5+sqrt(276)*rannor(1688));
label
vstestcd ='Vital Parameter Name'
vsstresn ='Vital Parameter Value'
vsstresu ='Vital Parameter Unit'
;
output;
end;
end;
run;
proc sort data=vital;
by usubjid;
run;
data vital(
3 REPLIES 3
Reeza
Super User

It's the DROP data set option. Usually it would be something like

 

<Data set Name> (DROP=<list variables> Rename=<rename list> etc...)

 

However if you only have one variable you can omit the parentheses.

 

Why you might see the following in code. 

 

data want;
set sashelp.class (rename=sex=gender);
run;

Data set options are documented here:

http://support.sas.com/documentation/cdl/en/ledsoptsref/68025/HTML/default/viewer.htm#n15goor3q758g5...

 

IMO the parenthesis requirements are inconsistent - ie you can't include them for DROP but you need them for RENAME sometimes. 

 

PGStats
Opal | Level 21

Dataset option DROP= signals to drop one or more variable. It can be used on input or output.

proc sort data=sashelp.class(drop=weight) out=myClass1(drop=age);
by age name;
run;

proc sql;
create table myClass2(drop=age) as
select * from sashelp.class(drop=weight)
order by age, name;
quit;

The two code blocks generate identical datasets. Variable weight is dropped on input, variable age is dropped on output after being used for sorting.

PG
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do be aware that using that method of coding is not really proper SQL or SAS, it is ahybrid of the two.  This can be confusing for SQL programmers and really isn't necessary.  It comes from the use of select * - which means take all columns from table - again, this is not really good practice for SQL, you should be selecting the columns you want to appear in your new table.  Using the select * is both lazy and dangerous - for instance if a variable is removed from the contributing tables, or new ones added your code may no longer function.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3713 views
  • 0 likes
  • 4 in conversation