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

Here is the basic idea:

123Goal
Person 1Household 1Wages - 10Household 1 Wages - 20
Person 2Household 2Wages - 10Household 2 Wages - 10
Person 3Household 1Wages - 10Household 1 Wages - 20

I'm trying to write an If/then statement that would search throughout all of column 2 to find similar household #'s and then find the sum and put them in the "goal column."

Would appreciate your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Tglass55
Calcite | Level 5

Sorry, let me try to be more specific. in a different question. 

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

The data you show us are all strings but you want to use the digits of column '3' as numeric values and sum them up. Not sure if your real data looks as posted or if this is already formatted data.

It would help in the future if you could post a proper SAS data step which creates sample data together with a description of how the expected result should look like. This way you're taking out the guess-work for us and you also have a better chance to get an answer which fits your actual data.

Below some code which deals with the data as posted.

data have;

  infile datalines truncover dlm=',' dsd;

  input (person household wages) (:$20.);

  datalines;

Person 1,Household 1,Wages - 10

Person 2,Household 2,Wages - 10

Person 3,Household 1,Wages - 10

;

run;

proc sql;

  create table want as

  select

    person,

    household,

    wages,

    catx(' ',household,'Wages',sum(input(scan(wages,-1,' -'),? best16.))) as goal length=40

  from have

  group by household

  order by person

  ;

quit;

Tglass55
Calcite | Level 5

Sorry, let me try to be more specific. in a different question. 

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1304 views
  • 0 likes
  • 2 in conversation