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
- /
- Make new observation from empty dataset.(0 obs dat...

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

03-06-2017 10:14 AM

I'm looking for ways to generate new obs from empty dataset(which have 0 obs).

Let's say you have 2 obs in adsl. From this data set, we create 0obs dataset(adsl_empty).

After that, please tell me if you know how to generate only 1obs with USUBJID = "No patients"; As I get "0 obs" after executing below sample. I want this to be 1 OBS in "adsl_x" dataset.

```
data work.adsl;
USUBJID ="xx1";output;
USUBJID ="xx2";output;
run;
data work.adsl_empty;
set work.adsl;
delete;
run;
data work.adsl_X;
set work.adsl_empty;
USUBJID = "No patients";output;
run;
```

Regards

Accepted Solutions

Solution

03-06-2017
10:31 AM

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

03-06-2017 10:27 AM

Here's a simple DATA step approach:

data want;

if 5=4 then set adsl_empty;

USUBJID = 'No Patients';

output;

run;

One issue you may need to address is the length of the variable USUBJID. It has to be at least 11 characters long in ADSL_EMPTY, in order to be able to fit the full text within "No Patients".

All Replies

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

03-06-2017 10:22 AM

You can do it in a variety of ways:

data step - set empty and new dataset with your data in example:

data temp; usubjid="No subjects"; run; data adsl; set adsl_blank temp; run;

proc append - put one dataset under another

proc sql - union all, selelct * from each

proc sql insert into

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

03-06-2017 10:34 AM

Thank you RW9.

I appreciate your telling me many ways for this.

I appreciate your telling me many ways for this.

Solution

03-06-2017
10:31 AM

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

03-06-2017 10:27 AM

Here's a simple DATA step approach:

data want;

if 5=4 then set adsl_empty;

USUBJID = 'No Patients';

output;

run;

One issue you may need to address is the length of the variable USUBJID. It has to be at least 11 characters long in ADSL_EMPTY, in order to be able to fit the full text within "No Patients".

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

03-06-2017 10:33 AM

Thank you Astounding.

This way is very simple and clear.

I also care length of USUBJID variable.

This way is very simple and clear.

I also care length of USUBJID variable.