BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmnagasree
Calcite | Level 5
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.
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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?

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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?

kmnagasree
Calcite | Level 5
thank you

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 709 views
  • 0 likes
  • 2 in conversation