PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 10, 2022

[FIXED] how to combine two variables data into two rows in SAS

 November 10, 2022     proc, sas, sas-macro, sql, transpose     No comments   

Issue

We have three variables in sas dataset and we want to create a new variable which would have values transposed for 2 variables and the third remain as it is.

Eg:

Acct_nb repl_acct_nb amount
12334       45678     100
23456       .         200

Output needed:

 new_acct_nb amount
 12334       100
 45678       100
 23456       200

Solution

I think this is what you want. Since, it is only 2 variables, no need for array logic.

data have;
input Acct_nb repl_acct_nb amount;
datalines;
12334 45678 100 
23456 .     200 
;

data want(keep =  new_acct_nb amount);
   set have;
   new_acct_nb = Acct_nb;
   if new_acct_nb then output;
   new_acct_nb = repl_acct_nb;
   if new_acct_nb then output;
run;


Answered By - PeterClemmensen
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing