BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
StefB
Calcite | Level 5

Hi there,

I have imported some data into SAS and I need to change the setup in one of the variables.  The variable data is called discharge_date and for those that have a double hyphen -- I need to put no, and those you have a date to say yes.  There are more double hyphens then dates.  Would this be an if/else statement?  I am very new to SAS I don't know what I am doing half the time.  It is a character and the informat and format is $9.  Please help I am stumped.

 

My example:

 

DISCHARGE_DATE

--

--

--

--

22-Nov-16

22-Nov-16

22-Nov-16

22-Nov-16

22-Nov-16

--

--

--

--

--

3-Sep-15

3-Sep-15

3-Sep-15

3-Sep-15

--

--

--

--

--

 

1 ACCEPTED SOLUTION

Accepted Solutions
Miracle
Barite | Level 11

Hi, yes an if/else will do if you are sure not going to use discharge_date for later analysis. If not, you are better to code them as a date variable. Otherwise the code is a follow:

* set new var to No if discharge_date is a character and strictly coded as double hyphen:
* else set to Yes; if discharge_date eq "--" then new_var="No"; else new_var="Yes";

 

View solution in original post

2 REPLIES 2
Miracle
Barite | Level 11

Hi, yes an if/else will do if you are sure not going to use discharge_date for later analysis. If not, you are better to code them as a date variable. Otherwise the code is a follow:

* set new var to No if discharge_date is a character and strictly coded as double hyphen:
* else set to Yes; if discharge_date eq "--" then new_var="No"; else new_var="Yes";

 

StefB
Calcite | Level 5

Thank you so much! It worked!

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
  • 514 views
  • 0 likes
  • 2 in conversation