02-20-2012 06:10 PM
I have a table that has multiple transposes of the date due to a member having multple admission dates. So the table looks like this: there are up to 30 different admission dates per member that are all different. it is the same with the discharge dates.
mbrId admitdt1 admitdt2 admitdt3 admitd4 etc dischdt1 dischtdt2 dischdt3 dischdt4 etc
I have a case statement that works but I want it to all be put into 1 column. case statement right now is
create table claims9 as
case when admitdt2 is not null and (dischdt1 <> admitdt2) then (admitdt2 - dischdt1) end as time1,
case when admitdt3 is not null and (dischdt2 <> admitdt3) then (admitdt3 - dischdt2) end as time2
this continues for all 30 admit and disch dates.
what i really want is to have all 30 be put into one column instead of ending each as its own time. this is because I have my 2nd query where I need to count the elapsed time between and it is just too big doing it 1 by 1. I thought maybe I could redo the case to be like this:
create table claims9 as
case when ((admitdt2 is not null) and (dischdt1 <> admitdt2) then (admitdt2 - dischdt1) and
(admitdt3 is not null) and (dischdt2 <> admitdt3) then (admitdt3 - dischdt2) )end as elapsed_time
of course there are 30 variations. Is there a way to code a case statement like that?
02-20-2012 06:25 PM
Not sure what you mean. An example have and want, with data, would help.
If only one of the conditions are ever true, which one would assume if you want it all combined in one column, then I would think that using max(admitdt might work.
02-20-2012 06:37 PM
I don't think you can use the colon operator in SQL, but you could in a datastep.
The data format does seem to scream arrays, so you may want to consider using an array within a datastep instead.
array admit(30) admitdt1-admitdt30;
elapsed_time=max(of admit(*))-min(of admit(*));
That assumes I have any idea of what you're actually after of course
02-20-2012 06:47 PM
Fareeza is, of course, correct. But you can easily get around that limitation. E.g.,:
set sashelp.class (rename=(age=v1 height=v2 weight=v3));
proc sql noprint;
select name into :vars
separated by ','
where libname="WORK" and
name like "v%"
create table want as
select name,sum(&vars.) as total
02-20-2012 11:50 PM
If you use the advanced editor (Click where it says "Use advanced editor" in the upper right of the reply form) there is a button below the edit field label "Choose File". This will let you select a file on your PC and it will be uploaded, zipped and attached to your message.
02-23-2012 07:54 AM
You are not alone. Check this thread out: http://communities.sas.com/thread/30153
After you have tried all of the tricks that people have suggested and still no avail, then you are in the same boat with me.
Some 'computer+internet brower' combination just wouldn't do it. I ended up using a portable browser (opera) to do the job. It can be run from an usb thumb drive, no need to install, so no IT involved if you are using company computer. here is the link: http://www.opera-usb.com/operausben.htm