BookmarkSubscribeRSS Feed
zhuxiaoyan1
Quartz | Level 8

Can anybody translate this excel code IF(A6=A5,IF(B6=B5,IF(C6=C5,IF(D6<=E5+1,F5,F5+1),F5+1),F5+1),F5+1) into SAS code?

Thanks!

4 REPLIES 4
Reeza
Super User

You're better off converting that to a logic requirement and then someone can help implement the code in SAS. One to one conversion is rarely a good idea, there's possibly a totally different way of implementing this in SAS. 

 

It looks like you're incrementing based on some sort of logic by checking if the records are the same?

 

Sample input and output data are also very helpful, character vs numeric variables can affect how the solution is implemented.

 

zhuxiaoyan1
Quartz | Level 8
Here is my data set. The Admit_ID is the variable I need to create.
ballardw
Super User

@zhuxiaoyan1 wrote:
Here is my data set. The Admit_ID is the variable I need to create.

The attachment looks like it didn't make it.

In case you attempted a an Excel file many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

You can follow instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... to turn you SAS data set into data step code that can be posted directly to the forum or attach as a text file.

ballardw
Super User

Do you have a SAS data set? Post a few rows of example input data from the SAS data set and the desired output.

 

Note that the the function in SAS to look at the value of a variable in a previous row is LAG.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1025 views
  • 3 likes
  • 3 in conversation