07-26-2016 06:48 PM
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(
07-26-2016 06:53 PM
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.
07-26-2016 10:45 PM
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.
07-27-2016 04:27 AM
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.