Hi,
I have a data in which i have to copy value into rows.
ex:
Site Subject Visit_Name
Abc Hospital A101 Screening
Visit1
Visit2
Visit3
AIIMS C102 Screening
Visit1
Visit2
Visit3
So i want to fill the row wise.
i have tried with macro.
but i am unable to understand.
%macro fillin;
%do i = 1 %to 5;
data two; set two;
temp =lag(Site_Id);
if temp NE " " and Site_Id = " " then Site_Id = temp;
run;
%end;
%mend fillin;
%fillin;
Here " %do i = 1 %to 5;" .
i don't want to specify 5 as number as that is not defined.
how to put %do syntax so that it will fill same value till it finds next one.
Thanks in advance.\
Regards,
B
SAS is not a spreadsheet.
What are you really wanting to do?
A data structure like:
site- values abc, aimms
subject- values A101, C102
visit_type- values screening, regular, special
visit_date - date mm/dd/yyyy
Would allow you to determine "first" visit by date.
Perhaps you could provide more info, some sample data, and/or a sample of the type of query or result you hope to run against or get from the data.
To some extent, I'm guessing at what you are trying to achieve Here's a program you can experiment with:
data halfway;
set have;
if site > ' ' then group + 1;
run;
data want;
update halfway (obs=0) halfway;
by group;
output;
drop group;
run;
If you are concerned ONLY with the variable SITE, we might be able to adjust this. But let's start here and see if this version does what you want.
Hi,
Please find the excel sheet attached.
i want to fill down the above row values till it is blank.
hope you understood what i am saying.
Kindly help me.
Regards,
B
Did you actually try running the program I posted?
If you did, how were the results? Exactly what you wanted? Close to what you wanted?
I have SAS in VM and it's opening very slow. So i am unable to run it.
else i would have check this.
Regards,
B
Please find the excel sheet attached.
Yes. As noted, SAS is not a spreadsheet.
Again, what are you really wanting to do?
Perhaps you could provide more info, some sample data, and/or a sample of the type of query or result you hope to run against or get from the data.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.