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(
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:
IMO the parenthesis requirements are inconsistent - ie you can't include them for DROP but you need them for RENAME sometimes.
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.
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.
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.
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.