BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PsycResearcher
Calcite | Level 5

Hi all,

I have a question about data management in SAS, and I wonder if anyone can help me.

I have an extremely large dataset. One column of the data represents data entered before the year 2005. Another column of data represents data entered after the year 2005. It looks like following:

ColumnAColumnB
.7
.9
.6
.5
.3
3.
4.
5.
8.

( . represents missing data)

If I want to combine two columns into one (let's name it columnC, is there a way to do so in SAS?)

Thank you very much for your help!

Chester

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

If the missing values are irrelevant, you might be able to use something like:

data have;

  input columna columnb;

  cards;

. 7

. 9

. 6

. 5

. 3

3 .

4 .

5 .

8 .

;

data want;

  set have (keep=columnb rename=(columnb=columnc)

             where=(not missing(columnc)))

      have (keep=columna rename=(columna=columnc)

             where=(not missing(columnc)));

run;

View solution in original post

7 REPLIES 7
art297
Opal | Level 21

If the missing values are irrelevant, you might be able to use something like:

data have;

  input columna columnb;

  cards;

. 7

. 9

. 6

. 5

. 3

3 .

4 .

5 .

8 .

;

data want;

  set have (keep=columnb rename=(columnb=columnc)

             where=(not missing(columnc)))

      have (keep=columna rename=(columna=columnc)

             where=(not missing(columnc)));

run;

MikeZdeb
Rhodochrosite | Level 12

Hi ... another idea ...

data have;

input columna columnb;

cards;

. 7

. 9

. 6

. 5

. 3

3 .

4 .

5 .

8 .

;

run;

data want;

set have;

columnc = coalesce(of col:) ;

keep columnc;

run;

PsycResearcher
Calcite | Level 5

Thanks for all your help!

I am new to SAS and I wonder if I can ask you another question about proc content? I am trying to ask SAS to list the variables with descriptions in a dataset but SAS keeps showing the variables in alphabetical orders. Is it possible to ask SAS to list the variables in the order they are in the dataset?

The syntax that I used is as follow:

proc content data=work.datafile;

run;

Thank you very much again!

Chester

NN
Quartz | Level 8 NN
Quartz | Level 8

Had read somewhere that in proc contents the VARNUM variable give you the position of the variable. Cannot confirm this right now so please check it once.

Peter_C
Rhodochrosite | Level 12

VARNUM option provides the "logical" order

The internal storage order will often be different

The "logical" order is the order in which the variables are "discovered" by the compiler

art297
Opal | Level 21

I think you want the order=varnum option.  The options are described in the following link:

http://support.sas.com/community/newsletters/news/techtips/OrderOption.html

PsycResearcher
Calcite | Level 5

Thanks for being helpful!

Chester

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 859 views
  • 6 likes
  • 5 in conversation