Blank in variable name? Trying to break the rules......

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 120
Accepted Solution

Blank in variable name? Trying to break the rules......

The attached NCDebt.csv file is the input file for the code in the attached .txt file labelled "Code." The code runs the way that I want it to, but I have the following item that I need to address.

The "Desired Output.txt" file is not generated by the code, however, it holds the structure that I want my Code-generated output to follow; you will notice similarities in the structure of the output generated once you run the code and the structure of the contents in the "Desired Output.txt file." My problem is that I cannot think of a way to write SAS code such that I can add the 'end' line found at the bottom of the Desired Output.txt file. I have commented out the "End='end'" line in the second datastep of my Code (this was my last ditch effort); when I transpose in the proc step, however, I am still stuck with the variable name End, which I don't want. Ideally, I would have a blank in the variable name and retain the value 'end.'

Any takers?

Attachment
Attachment
Attachment

Accepted Solutions
Solution
‎09-08-2014 05:55 PM
Grand Advisor
Posts: 10,210

Re: Blank in variable name? Trying to break the rules......

Sorry about the put _all_ error. This may come closer, change the name of the file to what you want for your text file.

data _null_;

file 'd:\data\output.txt';

set work.Ncdebt3 end= last;

put _NAME_ col1-col9;

if last then put 'End';

run;

I suspect the unwanted END variable is occurring because of the RETAIN statement when creating NCDebt2. I removed that from the data step then ran the transpose code and the above.

View solution in original post


All Replies
Grand Advisor
Posts: 10,210

Re: Blank in variable name? Trying to break the rules......

Maybe something like;

data _null_;

     file 'Your desired output file name goes here';

     set Ncdebt3 (end= last);

     put _all_;

     if last then put 'End';

run;

Frequent Contributor
Posts: 120

Re: Blank in variable name? Trying to break the rules......


I tried the following; still no go.

data test;

     set Ncdebt3 end= last;

     put _all_;

     if last then put 'end';

run;

Respected Advisor
Posts: 4,606

Re: Blank in variable name? Trying to break the rules......

"Still no go" is not a very good description of what you got!

PG
Frequent Contributor
Posts: 120

Re: Blank in variable name? Trying to break the rules......

PGStats,

My apologies; by "still no go" I meant that I did not achieve my desired result; the Ncdebt3 dataset in my code above remains unchanged. I attach my log if it helps.

Attachment
Respected Advisor
Posts: 4,606

Re: Blank in variable name? Trying to break the rules......

Why is obs #3 skipped (with firstobs=4)? Why would there be only 6 values present in the multi-valued rows of Desired Output.txt? What would make some rows multi-values and others not, in Desired Output.txt?

PG
Frequent Contributor
Posts: 120

Re: Blank in variable name? Trying to break the rules......

PGStats,

The end-goal of my code is to prepare a .txt file to be fed into a model. The multi- vs single- value rows issue is somewhat arbitrary and is model-dependent, so I don't have a clear-cut rule to give you. Starting at observation 4 is also model-driven. Mind you, however, that none of the two issues that you raise are related to my original question.

I hope this helps.

Grand Advisor
Posts: 10,210

Re: Blank in variable name? Trying to break the rules......

The code I posted is NOT intended to create a dataset but an output TEXT file which was sort of implied by the use of "desired output text" as the zip file demonstrated. If you want a data set then some more specific description of the output is needed.

Solution
‎09-08-2014 05:55 PM
Grand Advisor
Posts: 10,210

Re: Blank in variable name? Trying to break the rules......

Sorry about the put _all_ error. This may come closer, change the name of the file to what you want for your text file.

data _null_;

file 'd:\data\output.txt';

set work.Ncdebt3 end= last;

put _NAME_ col1-col9;

if last then put 'End';

run;

I suspect the unwanted END variable is occurring because of the RETAIN statement when creating NCDebt2. I removed that from the data step then ran the transpose code and the above.

☑ This topic is SOLVED.

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

Discussion stats
  • 8 replies
  • 238 views
  • 0 likes
  • 3 in conversation