BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a txt file (.asc) of Survey data (more than 100 variables Q1-Q100), with variable label and variable coding list as separated parts in the txt file (.asc).

Is there any systematic methods to read this file? I mean, label all variables, and coding each variable in a systematic way rather than re_label and code (proc format) each variable one by one in SAS?


Thanks in advance.
1 REPLY 1
deleted_user
Not applicable
that sounds like a commercial service that should have been commissioned/provided along with the data.

For variable-coding you would want to create cntlin= data set for proc format. For re-labelling columns you would want to generate the "variable = 'label' " text for proc datasets.

There are probably features in the data that help you recognise the separate types of data/information.
Use these criteria to create data sets from which you can build the relevant metadata with code like : [pre]
%let infile = your.survey.asc ;
data yourLib.data_data_part( label="data loaded %now")
yourLib.label_metadata( label="from &infile" keep= name label )
yourLib.variable_codes( label="&infile var codes" keep= name value label type )
;
infile "&infile" .......................... ;
.................
if {criteria defines variable label} then output yourLib.label_metadata ;
else
if {criteria defines variable codes} then output yourLib.variable_codes ;
else
if {criteria defines data } then output yourLib.data_data_part ;
run;[/pre] That is just schematic... What follows is code you might use for building and applying variable labels from label metadata [pre]
proc sql noprint ;
select trim(name) !! '=' !! quote(trim(label))
into :labelling separated by ' '
from label_metadata( keep= name label )
;
quit;
proc datasets library =yourLib nolist ;
modify data_data_part ;
Label &label_metadata ;
run;
quit;[/pre]

Good Luck

PeterC

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 821 views
  • 0 likes
  • 1 in conversation