DATA Step, Macro, Functions and more

NOTE: Variable COLUMN NAME is uninitialized in sas

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

NOTE: Variable COLUMN NAME is uninitialized in sas

Hi , 

I am trying to export the out put text file and I am able to export the file , but one of the column (amt)results are not showing up in the output text file .. but in SAS EG output data is populating all the results ,  log is showing as  'NOTE: Variable amt is uninitialized in sas ' 

 

could anyone can help 

 

data have;
  name="Thomas"; city="New Jersy"; country="USA";amt = 150 ;id="1000"; output;
  name="David"; city="New Jersy"; country="USA";amt=100; id="1005"; output;
run;

data _null_;
  set have nobs=num_obs end=last;
  file "s:\temp\rob\text.txt";
  if _n_=1 then put @1 "AL16" @31 "0000";
  put Name $ 1 - 17
      City $ 18 - 25
      Country $ 26 - 30
amt & 31 - 36 Id $ 37 - 40; tmp=strip(put(num_obs,z3.)); if last then put @1 "DL99" @31 tmp; run; 

out put text file :

Thomas newjersy usa  1000

David newjersy usa  1005

 

 

* AMT 100 AND 150 ARE MISSING

 

Thanks

 


Accepted Solutions
Solution
‎12-15-2016 08:03 PM
Super User
Posts: 6,963

Re: NOTE: Variable COLUMN NAME is uninitialized in sas

Can't be.

Running your code (only changed the filename) gave me this log:

16         data have;
17           name="Thomas"; city="New Jersy"; country="USA";amt = 150 ;id="1000"; output;
18           name="David"; city="New Jersy"; country="USA";amt=100; id="1005"; output;
19         run;

NOTE: The data set WORK.HAVE has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

20         
21         data _null_;
22           set have nobs=num_obs end=last;
23           file "$HOME/sascommunity/text.txt";
24           if _n_=1 then put @1 "AL16" @31 "0000";
25           put Name $ 1 - 17
26               City $ 18 - 25
27               Country $ 26 - 30
28               amt & 31 - 36
29               Id $ 37 - 40;
30           tmp=strip(put(num_obs,z3.));
31           if last then put @1 "DL99" @31 tmp;
32         run;

NOTE: The file "$HOME/sascommunity/text.txt" is:
      Filename=/home/xxxxxxxx/sascommunity/text.txt,
      Owner Name=xxxxxxxx,Group Name=yyyyyyyy,
      Access Permission=rw-r--r--,
      Last Modified=Thu Dec 15 09:02:31 2016

NOTE: 4 records were written to the file "$HOME/sascommunity/text.txt".
      The minimum record length was 33.
      The maximum record length was 40.
NOTE: There were 2 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

No messages here that indicate anything went wrong.

This is the resulting file:

AL16                          0000
Thomas           New JersUSA  150   1000
David            New JersUSA  100   1005
DL99                          002

You can see that all values are present.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 17,905

Re: NOTE: Variable COLUMN NAME is uninitialized in sas

Include the exact output please. The answer shown doesn't align with your code. 

Solution
‎12-15-2016 08:03 PM
Super User
Posts: 6,963

Re: NOTE: Variable COLUMN NAME is uninitialized in sas

Can't be.

Running your code (only changed the filename) gave me this log:

16         data have;
17           name="Thomas"; city="New Jersy"; country="USA";amt = 150 ;id="1000"; output;
18           name="David"; city="New Jersy"; country="USA";amt=100; id="1005"; output;
19         run;

NOTE: The data set WORK.HAVE has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

20         
21         data _null_;
22           set have nobs=num_obs end=last;
23           file "$HOME/sascommunity/text.txt";
24           if _n_=1 then put @1 "AL16" @31 "0000";
25           put Name $ 1 - 17
26               City $ 18 - 25
27               Country $ 26 - 30
28               amt & 31 - 36
29               Id $ 37 - 40;
30           tmp=strip(put(num_obs,z3.));
31           if last then put @1 "DL99" @31 tmp;
32         run;

NOTE: The file "$HOME/sascommunity/text.txt" is:
      Filename=/home/xxxxxxxx/sascommunity/text.txt,
      Owner Name=xxxxxxxx,Group Name=yyyyyyyy,
      Access Permission=rw-r--r--,
      Last Modified=Thu Dec 15 09:02:31 2016

NOTE: 4 records were written to the file "$HOME/sascommunity/text.txt".
      The minimum record length was 33.
      The maximum record length was 40.
NOTE: There were 2 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

No messages here that indicate anything went wrong.

This is the resulting file:

AL16                          0000
Thomas           New JersUSA  150   1000
David            New JersUSA  100   1005
DL99                          002

You can see that all values are present.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 194

Re: NOTE: Variable COLUMN NAME is uninitialized in sas

Maybe it has to do with the use of an ampersand in the put statement.

It may not be supported by the version of SAS you're using.

What output do you obtain if you remove it ?

Occasional Contributor
Posts: 8

Re: NOTE: Variable COLUMN NAME is uninitialized in sas

Solved, it is because column names are different

 

Thanks

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 412 views
  • 0 likes
  • 4 in conversation