BookmarkSubscribeRSS Feed
elsfy
Quartz | Level 8

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  : 

isgnr_0-1647280689776.png

If for instance i have no product  then SAS gives me this output:

isgnr_1-1647280862939.png

but i want to see this output : 

 

isgnr_2-1647280890952.png

 

 

Thanks,

 

6 REPLIES 6
elsfy
Quartz | Level 8
the first image is not a table, i want to have an output with all the possibilities even if there is no information about it. Hope it is clear
PaigeMiller
Diamond | Level 26

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???

 

 

--
Paige Miller
elsfy
Quartz | Level 8

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.

PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
elsfy
Quartz | Level 8
Yes that’s correct
pink_poodle
Barite | Level 11

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 6 replies
  • 1002 views
  • 0 likes
  • 3 in conversation