Is there a way to keep a row even if it has no value and rather then deleting it (just like SAS does) , just keep the information from the first column and set the rest of the columns to empty values.
Here is an example :
Imagine i have these possible product ids and if the information is not available (no product found) about an id then rather than deleting the row (in the output) just keep the id column and fill the product and price column with an empty cell :
If for instance i have no product then SAS gives me this output:
but i want to see this output :
Thanks,
Is there a way to keep a row even if it has no value and rather then deleting it (just like SAS does)
SAS does not delete empty rows. You, the human user, have written SAS code that tells SAS to delete empty row. It certainly is possible to not delete empty rows.
Not sure what you are asking though. I need a better explanation of the logic. It seems as if you have data set #2, how would you know, as the programmer, what other IDs need to be in the data set???
I know the exact list of the different products that can be in a table (10 products max).
I can have 10 different rows for each product then.
For now what i did is a sas code based on conditions (e.g price > 2) so i get an output (name it tableA) with 5 rows.
But i want an output with 10 rows (i.e the maximum row possibility ) with tableA information and the other 5 rows (products) that don't respect the conditions displayed too but with no numerical value.
Thank you
What i imagined is creating a table and adding a row for each possible product (10 rows then).
Then merging it with tableA.
Thank you
What i imagined is creating a table and adding a row for each possible product (10 rows then).
Then merging it with tableA.
Yes, that is indeed what you want to do. But don't you mean a table which a row for each possible ID?
Sure, you can return an empty product and price for a product that is neither “bread” nor “cheese”:
Data want;
Set have;
If product not in (“bread”, “cheese”) then product = “.” And price = “.”;
Run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.