turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- translate excel code into SAS code

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-20-2016 12:22 PM

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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-20-2016 03:28 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-20-2016 03:55 PM

Here is my data set. The Admit_ID is the variable I need to create.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-20-2016 04:09 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-20-2016 03:37 PM

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.