BookmarkSubscribeRSS Feed
stancemcgraw
Obsidian | Level 7

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

 

4 REPLIES 4
Reeza
Super User

The error message is pretty clear. 

Run a proc contents to check your variable names are correct. 

Astounding
PROC Star

Which variable are you trying to create?  This code is trying to replace NIHISS.  It doesn't create anything new.

Kurt_Bremser
Super User
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.

cici0017
SAS Employee

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;

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1260 views
  • 0 likes
  • 5 in conversation