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

Hi, 

 

I am writting a program and want to assign the values of the existing variable to a new variable with some modification, but have a problem with it. the new variable VISNUMEN has the missing value. Any help is greatly appreciated. the coding is as the following:

 

	if VISITNUM=13 and strip(upcase(DSTERM))='PROTCOL COMPLETED' then VISNUMEN=12;
	else if VISITNUM=12 and strip(upcase(DSTERM))='PROTCOL COMPLETED' then VISNUMEN=VISITNUM;

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Fix these two issues and you'll solve your problem:

NOTE: Numeric values have been converted to character values at the places given by: (Line)Smiley SadColumn).
71:34 72:39
NOTE: Variable DSTERM is uninitialized.
 
VISITNUM is likely character so you should have the values in quotes in the IF.
DSTERM is not a variable in your dataset so your condition is never met, so all values are missing.
 
Read your log. 

View solution in original post

7 REPLIES 7
Reeza
Super User

It has all missing values or some missing values? Are you sure all conditions are being capture by your logic?

 

The easiest way to check something like this is to use a PROC FREQ with the new and old values.

 

proc freq data=have;
where strip(upcase(dsterm)) = 'PROTOCOL COMPLETED' ;

table visitnum*visnumen;

run;
SAS_John
Obsidian | Level 7

Thanks Reeza for the response. Yes, it is all missing values.

SAS_John
Obsidian | Level 7

Here the coding purpose is to change the vaule of '13' for VISITNUM to the vaule of '12' of VISNUMEN. it seems that this did not work

Reeza
Super User

1. What does your log say?

2. What's the type and format of visitnum

SAS_John
Obsidian | Level 7
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 data ds;
57 set sdtm.ds(rename=(DSDECOD=DSDECOD_ DSTERM=DSTERM_));
58
59 where strip(upcase(DSCAT))='DISPOSITION EVENT';
60
61 length DCDECOD $27 DCREASCD $50 DISCONFL DSRAEFL $1 VISNUMEN 8.;
62 DCDECOD=DSDECOD_;
63 DCREASCD=DSTERM_;
64
65 if strip(upcase(DSDECOD_))^='COMPLETED' then DISCONFL='Y';
66 else DISCONFL='';
67
68 if strip(upcase(DSDECOD_))='ADVERSE EVENT' then DSRAEFL='Y';
69 else DSRAEFL='';
70
71 if VISITNUM=13 and strip(upcase(DSTERM))='PROTCOL COMPLETED' then VISNUMEN=12;
72 else if VISITNUM=12 and strip(upcase(DSTERM))='PROTCOL COMPLETED' then VISNUMEN=VISITNUM;
73
74 keep USUBJID DCDECOD DCREASCD DISCONFL DSRAEFL DSSTDTC VISNUMEN;
75 label DCDECOD='Standardized Disposition Term'
76 DCREASCD='Reason for Discontinuation'
77 DISCONFL='Did the Subject Discontinue the Study?'
78 DSRAEFL='Discontinued due to AE?'
79 VISNUMEN='End of Trt Visit (Vis 12 or Early Term.)'
80 ;
81 run;
 
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
71:34 72:39
NOTE: Variable DSTERM is uninitialized.
NOTE: There were 306 observations read from the data set SDTM.DS.
WHERE STRIP(UPCASE(DSCAT))='DISPOSITION EVENT';
NOTE: The data set WORK.DS has 306 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.27 seconds
cpu time 0.23 seconds
 
 
Reeza
Super User

Fix these two issues and you'll solve your problem:

NOTE: Numeric values have been converted to character values at the places given by: (Line)Smiley SadColumn).
71:34 72:39
NOTE: Variable DSTERM is uninitialized.
 
VISITNUM is likely character so you should have the values in quotes in the IF.
DSTERM is not a variable in your dataset so your condition is never met, so all values are missing.
 
Read your log. 
kiranv_
Rhodochrosite | Level 12

you may need to give a else statement. If you can do not give else statement, then you will get null if scenarious you have mentioned does not cover all the records. you should probably do else varnum = somevalue

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!

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
  • 7 replies
  • 5541 views
  • 0 likes
  • 3 in conversation