BookmarkSubscribeRSS Feed
allurai0412
Fluorite | Level 6

hi ,

My data looks like this ..

For JOINT MODE and ANYONE OR SURVIVOR ...>PANGNO , PANGNO2 ...should and must be there.

For Single ..............> only one filed PANGNO ......should be there..

SLNOMOHDESCJOINT1 NAMEPANGNOPANGNO2
1JOINT MODEMRUNALINIAACPD**********9755K
2JOINT MODEALLUAHEPS**********7493Q
3ANYONE OR SURVIVORHANSAAKJPS**********9102J
4ANYONE OR SURVIVORSHAHAKJPS**********9103K
5ANYONE OR SURVIVORCHANDRAAACPS**********8379A
6ANYONE OR SURVIVORVISHWANATHAHPPP**********8187B
7ANYONE OR SURVIVORSARITAACPT**********6408C
8SINGLEJOYCEABQPT*****
9SINGLELALKUMAR CHHEDAAAAPC*****
10SINGLERAJNIAABPT**********9260F
11SINGLEPAREKHACDPP**********0067L
12ANYONE OR SURVIVORRACHANAACZPG**********4471F
13ANYONE OR SURVIVORMUKTAAAAPP**********9000A
14ANYONE OR SURVIVORSUMITABIPB**********0438P

My output requires like this..

SLNOMOHDESCJOINT1 NAMEPANGNOPANGNO2Authorisation of trans
1JOINT MODEMRUNALINIAACPD**********9755KBoth
2JOINT MODEALLUAHEPS**********7493QBoth
3ANYONE OR SURVIVORHANSAAKJPS**********9102JAny
4ANYONE OR SURVIVORSHAHAKJPS**********9103KAny
5ANYONE OR SURVIVORCHANDRAAACPS**********8379AAny
6ANYONE OR SURVIVORVISHWANATHAHPPP**********8187BAny
7ANYONE OR SURVIVORSARITAACPT**********6408CAny
8SINGLEJOYCEABQPT*****0single
9SINGLELALKUMAR CHHEDAAAAPC*****0single
10SINGLERAJNIAABPT**********9260Finvalid
11SINGLEPAREKHACDPP**********0067Linvalid
12ANYONE OR SURVIVORRACHANAACZPG**********4471FAny
13ANYONE OR SURVIVORMUKTAAAAPP*****0invalid
14ANYONE OR SURVIVORSUMITABIPB*****0invalid

Regards

ALLU

6 REPLIES 6
esjackso
Quartz | Level 8

Is the question how to make the last column in the output? Not clear on the help that is needed.

EJ

allurai0412
Fluorite | Level 6

yes...the question about the last coulmn....


esjackso
Quartz | Level 8

See if this works.  Check the capitalization of the data to make sure the code matches the data.

data output;

     length auth $ 15;

     set data;

     auth = "Invalid";

     if MOHDESC in ("JOINT MODE" "ANYONE OR SURVIVOR") and PANGNO ne "" and PANGNO2 ne "" then do;

          if mohdesc = "JOINT MODE" then auth = "Both";

               else auth = "Any";

     end;

          else if MOHDESC = "SINGLE" and (PANGNO ne "" or PANGNO2 ne "") then auth ="single";

run;

allurai0412
Fluorite | Level 6

hi...

i need the condition for  "SINGLE "

like this

it should and must have only one "PANGNO ".... will below code , that you have provided works ??

"

  else if MOHDESC = "SINGLE" and (PANGNO ne "" or PANGNO2 ne "") then auth ="single";

"

regards

ALLU

esjackso
Quartz | Level 8

if it you want to check for only one PAGNO for Single I would do something like the following:

  else if MOHDESC = "SINGLE" and ((PANGNO ne "" and  PANGNO2 = "")  or ((PANGNO = "" and  PANGNO2 ne ""))

then auth ="single";

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1047 views
  • 3 likes
  • 2 in conversation