I am trying to create a new variable from an exisitng one, but whenever I try, it says variable uninitialized. What is the problem?
libname Iat '\\vmware-host\Shared Folders\Desktop\SAS\IAT\';
PROC IMPORT OUT= X.X
DATAFILE= 'timetoiat'
DBMS=CSV REPLACE;
GETNAMES=YES;
GUESSINGROWS=X;
DATAROW=X;
RUN;
proc import datafile="\\vmware-host\Shared Folders\Desktop\SAS\IAT\timetoiat"
out=Iat.timetoiat dbms=xlsx replace;
sheet="Sheet1";
getnames=yes;
run;
Data iat;
set iat.timetoiat;
IF NIHSS LE 16 THEN NIHSS=NIHSSLT16;
IF NIHSS >=16 THEN NIHSS=NIHSSGTE16;
RUN;
log:
20 Data iat;
21 set iat.timetoiat;
22 IF NIHSS LE 16 THEN NIHSS=NIHSSLT16;
23 IF NIHSS >=16 THEN NIHSS=NIHSSGTE16;
24 RUN;
NOTE: Variable NIHSSLT16 is uninitialized.
NOTE: Variable NIHSSGTE16 is uninitialized.
NOTE: There were 380 observations read from the data set IAT.TIMETOIAT.
NOTE: The data set WORK.IAT has 380 observations and 24 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
The error message is pretty clear.
Run a proc contents to check your variable names are correct.
Which variable are you trying to create? This code is trying to replace NIHISS. It doesn't create anything new.
20 Data iat; 21 set iat.timetoiat; 22 IF NIHSS LE 16 THEN NIHSS=NIHSSLT16; 23 IF NIHSS >=16 THEN NIHSS=NIHSSGTE16; 24 RUN; NOTE: Variable NIHSSLT16 is uninitialized. NOTE: Variable NIHSSGTE16 is uninitialized.
this simply means that there are no variables NIHSSLT16 and NIHSSGTE16 in dataset iat.timetoiat.
Have a look at your infile you use in PROC IMPORT. I also noted that you import into library LAT, but use IAT.timetoiat in your DATA step.
Your previous code is replacing the value of NIHSS but not created variables NIHSSLT16 and NIHSSGTE16, you should have code:
Data iat;
set iat.timetoiat;
IF NIHSS LE 16 THEN NIHSSLT16=NIHSS;
IF NIHSS >=16 THEN NIHSSGTE16=NIHSS;
RUN;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.