Data ds1;
Input pid drug$ visit_date date9.;
Format visit_date date9.;
Cards;
101 asp-05mg 12jan2005
102 asp-10mg 14jan2005
101 asp-05mg 18jan2005
102 asp-10mg 12jan2005
101 asp-05mg 21jan2005
103 asp-15mg 12jan2005
101 asp-05mg 30jan2005
102 asp-10mg 12jan2005
101 asp-05mg 23jan2005
102 asp-10mg 12jan2005
101 asp-05mg 11jan2005
103 asp-15mg 12jan2005
101 asp-05mg 15jan2005
104 asp-20mg 12jan2005
101 asp-05mg 16jan2005
102 asp-10mg 12jan2005
103 asp-15mg 12jan2005
103 asp-15mg 12jan2005
101 asp-05mg 15jan2005
;
Run;
data f;
set ds1;
visit_date=date ;
informat date date10.;
format date date10.;
run;
i am unable to get the values in date variable.
please guide me.
thank you.
What is the purpose of the second data step?
data f;
set ds1;
visit_date=date ;
informat date date10.;
format date date10.;
run;
It looks like you are creating a new (and hence totally missing) variable and then using it to overwrite the variable VISIT_DATE that you read from the DS1 dataset.
Perhaps you meant to do this?
data f;
set ds1;
date = visit_date ;
format date date9.;
run;
Not sure what value using a width of 10 does for the DATE format. DATE9 will print with four digit years. DATE11 will add hyphens around the month.
Also not sure what value is added by assigning an INFORMAT to a variable that is not being used to read from raw data. It doesn't hurt, but why bother?
What is the purpose of the second data step?
data f;
set ds1;
visit_date=date ;
informat date date10.;
format date date10.;
run;
It looks like you are creating a new (and hence totally missing) variable and then using it to overwrite the variable VISIT_DATE that you read from the DS1 dataset.
Perhaps you meant to do this?
data f;
set ds1;
date = visit_date ;
format date date9.;
run;
Not sure what value using a width of 10 does for the DATE format. DATE9 will print with four digit years. DATE11 will add hyphens around the month.
Also not sure what value is added by assigning an INFORMAT to a variable that is not being used to read from raw data. It doesn't hurt, but why bother?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.