comp.soft-sys.sas - The SAS statistics package.
Hi, Could I have some advice please as I need to convert a datetime field to a date but I cannot use datepart() and need to use PROC SQL. Would it be something like this substr(to_char(mydatetimefield,n,n,)) Thanks Lee
Hi everyone, I have a data set that has a mutiple client id's 2-3 max per observation. I also have multiple surgery dates (as another field). My question is, how do I select/keep the observations that had the same date of surgery? data ex: id surgdate 1 01JAN2000 1 01JAN2000 2 23FEB2003 2 30FEB2003 So for this dataset, I want to keep ID =1 but not id=2. I'm just having a mental block here on how to do comparisons within a field looping through the ID's. TIA, Neerav
In the following data step example, dataset a is read only once to create the three sub-datasets (a1, a2, a3). How to implement this in Proc SQL without efficiency sacrifice? Thanks! data a; input x; cards; 1 2 3 5 4 9 2 1 6 ; run; data a1 a2 a3; set a; if x=1 then output a1; else if x=2 then output a2; else output a3; run;
I am using Proc SQL into and Separated by clause to create more than one macro variable based on on a single column and a dynamic where condition. The dataset dept1 may contain many depts and groups . Here is my code: --------------------------------- options symbolgen mlogic; data dept1; input dept group; datalines; 1 1 3 1 2 1 60 2 70 2 80 2 90 2 200 3 300 3 ; run; proc sql noprint; select count(distinct group) into :group_count from dept1; quit; %let group_count=&group_count; %put &group_count; proc sql noprint; select distinct group into :group1 - :group&group_count from dept1; quit; %macro read(); %local i; %do i=1 %to &group_count; %let group&i=&&group&i; proc sql ; select dept into :dept_grp&i separated by ',' from dept1 where group=&&group&i; quit; %end; %mend read; %read(); %put &dept_grp1 &dept_grp2 &dept_grp3; My problem is &dept_grp1 &dept_grp2 &dept_grp3 are not getting created. Please help me with your thoughts. Thanks.