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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

4 REPLIES 4
Reeza
Super User

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

Kurt_Bremser
Super User

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.

gamotte
Rhodochrosite | Level 12

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 ?

tvbMadhu
Calcite | Level 5

Solved, it is because column names are different

 

Thanks

 

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