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

I have a table as below sample:I wanted to update UDF_value of the matching CASE_RK when udf_nm='x_case_prd' .so I wanted to see 2016q3 to change 2016q4 for all x_case_prd when maching case_rk.Can I do that in just few steps. I can use substr and concatenate with write period but Need to know if there is another quick solution to this?

 

CASE_RK VALID_FROM_DTTM UDF_TABLE_NM UDF_NM ROW_NO UDF_VALUE
3837195 xx CASE X_CASE_PRD 1

2016Q3

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

Sounds pretty straight-forward....

proc sql;

update work.have

set udf_value = '2016q4'

where udf_nm='X_CASE_PRD' ;

quit;

View solution in original post

4 REPLIES 4
DBailey
Lapis Lazuli | Level 10

I could not understand what you wanted to do.

 

Typically, you can update datasets via proc sql:

 

If you want to update the new column to a null value if it can't find a match, then you might use something like this:

proc sql;

update work.have as t1

set t1.udf_value=(select new_value from some_data_set where col=t1.col)

where t1.udf_nm='X_CASE_PRD' ;

quit;

 

If you want to update the new column only when there is a match, you can add to the criteria:

proc sql;

update work.have as t1

set t1.udf_value=(select new_value from some_data_set where col=t1.col)

where t1.udf_nm='X_CASE_PRD'  and exists (select new_value from some_data_set where col=t1.col);

quit;

shuchidxt_gmail_com
Obsidian | Level 7

I am trying to update UDF_VALUE COLUMN from 2016q3 to 2016q4(so need to change the suffix quarter from q3 to q4)  where udf_name="X_CASE_PRD" .

DBailey
Lapis Lazuli | Level 10

Sounds pretty straight-forward....

proc sql;

update work.have

set udf_value = '2016q4'

where udf_nm='X_CASE_PRD' ;

quit;

shuchidxt_gmail_com
Obsidian | Level 7

Yes, I twisted the query above and it worked for me. Thank you

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1179 views
  • 0 likes
  • 2 in conversation