DATA Step, Macro, Functions and more

what does drop=i mean? I saw two programs that include this but I do not understand

Reply
Super Contributor
Posts: 345

what does drop=i mean? I saw two programs that include this but I do not understand

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(
Super User
Posts: 19,769

Re: what does drop=i mean? I saw two programs that include this but I do not understand

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. 

 

Respected Advisor
Posts: 4,919

Re: what does drop=i mean? I saw two programs that include this but I do not understand

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
Super User
Super User
Posts: 7,942

Re: what does drop=i mean? I saw two programs that include this but I do not understand

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.

Ask a Question
Discussion stats
  • 3 replies
  • 334 views
  • 0 likes
  • 4 in conversation